Eggzorcist Posted November 17, 2009 Share Posted November 17, 2009 this is the error I'm getting. Warning: Cannot modify header information - headers already sent by (output started at index.php:11) in functions.php on line 30 what I am trying to do is get the header to work in the functions.php file, functions.php is included at the very top of the page, I'm not sure why I'm getting this as an issue... Any help much appreciated, thanks Quote Link to comment Share on other sites More sharing options...
.josh Posted November 17, 2009 Share Posted November 17, 2009 read the sticky. Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted November 17, 2009 Author Share Posted November 17, 2009 I have read it and I'm still comfused. My header is before any html code... Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted November 17, 2009 Author Share Posted November 17, 2009 Is it because the header is already sent by the sessions and I cannot send the header()? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 17, 2009 Share Posted November 17, 2009 Read the error: output started at index.php:11 (line 11) You would need to determine what index.php is doing on (or up to) line 11 that is producing output and either eliminate it (assuming it is unintentional) or rearrange your logic (assuming the output is intentional) so that the output occurs after the header() statement or the header() statement is before the code sending the output. Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted November 17, 2009 Author Share Posted November 17, 2009 line 11 in index.php is html code... Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted November 17, 2009 Author Share Posted November 17, 2009 Here's my code... <?php require_once('functions.php'); if(isset($_POST['login'])){ login_user($_POST['login_email'], $_POST['login_pass']); } ?> <!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=UTF-8" /> <title>Login</title> </head> <body> <div id="login_error"> </div> <form id="login" method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <label>E-mail: <input type="text" name="login_email" id="login_email" /> </label> <label>Password: <input type="password" name="login_pass" id="login_pass" /> </label> <input type="submit" name="login" value="login" id="Login" /> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted November 17, 2009 Share Posted November 17, 2009 obviously line 11 is where your output starts. put the header above that... Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted November 17, 2009 Author Share Posted November 17, 2009 I'm comfused, the header() is within the login_user function isn't it already before line 11? Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted November 17, 2009 Share Posted November 17, 2009 hmm, can I see the login_user code? Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted November 17, 2009 Author Share Posted November 17, 2009 function login_user($email, $password){ $username = secure_var($email); $password = md5($password); if ($username != NULL and $password != NULL){ $login_query = mysql_query("SELECT * FROM user_info WHERE email = '$email' AND password = '$password'"); $login_status = mysql_num_rows($login_query); $login_vars = mysql_fetch_array($login_query); if($login_status == 1){ set_login_sessions($login_vars['email'], $password, $login_vars['auth']); header('Location: usercp.php'); exit; } else { echo "The entered username and/or password are incorrect. Please try again."; } } else { echo "Please enter a username and/or password."; } } [/code Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 17, 2009 Share Posted November 17, 2009 Your index.php file either has a bunch of crap before the <?php tag or your functions.php file is outputting something. If you put the opening <?php tag in index.php on a line by itself (move the require_once() statement down so it is on the line after the <?php tag) you can tell if the output is something in index.php or functions.php Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted November 17, 2009 Author Share Posted November 17, 2009 Can it be for example a function sending out sessions? or another include? Quote Link to comment Share on other sites More sharing options...
blacksmoke26 Posted November 17, 2009 Share Posted November 17, 2009 any char without <?php ?> or with echo ''; is an output. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted November 17, 2009 Share Posted November 17, 2009 The error doesn't seam to match your code, can you post the full functions.php and index.php also in your login_user function shouldn't email = '$email' be email = '$username' in the following $username = secure_var($email); $password = md5($password); if ($username != NULL and $password != NULL){ $login_query = mysql_query("SELECT * FROM user_info WHERE email = '$email' AND password = '$password'"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.