signature16 Posted June 26, 2007 Share Posted June 26, 2007 I know this is probably a simple problem to solve, but I can't figure it out. Please somebody help me! I am getting this error: Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\usersystem3\login.php:17) in C:\wamp\www\usersystem3\login.php on line 41 Here is my pages code. The include files just has the session start and the database connection. <?php require_once('include.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Login</title> </head> <body> <form action="<?php $PHP_SELF; ?>" method="post" > Email<br /> <input name="email" type="text" /><br /><br /> Password<br /> <input name="password" type="password" /><br /> <input name="submit" type="submit" value="Log In" /> </form> <?php $error = ''; $form = $_POST['submit']; $email = $_POST['email']; $password = $_POST['password']; if( isset($form) ) { if( isset($email) && isset($password) && $email !== '' && $password !== '' ) { echo "everythg is filled out. yay!"; $sql = mysql_query("SELECT * FROM `usersystem` WHERE email='$email' and password='$password';"); if( mysql_num_rows($sql) != 0 ) { //success $_SESSION['logged-in'] = true; header('Location: redirect.php'); /// RAWR!!!! WHATS WRONG?! exit; } else { $error = "Incorrect login info"; } } else { $error = 'All information is not filled out correctly';} } echo "<br /><span style=\"color:red\">$error</span>"; ?> </body> </html> Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/57226-solvedwarning-cannot-modify-header-information/ Share on other sites More sharing options...
Wuhtzu Posted June 26, 2007 Share Posted June 26, 2007 Read the sticky post first: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html You are getting the error because you output html/text to the browser before setting the session... Link to comment https://forums.phpfreaks.com/topic/57226-solvedwarning-cannot-modify-header-information/#findComment-282844 Share on other sites More sharing options...
signature16 Posted June 26, 2007 Author Share Posted June 26, 2007 I'm sorry I should have seen that post. I fixed the problem so thank you. Link to comment https://forums.phpfreaks.com/topic/57226-solvedwarning-cannot-modify-header-information/#findComment-282846 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.