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 Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/ Share on other sites More sharing options...
.josh Posted November 17, 2009 Share Posted November 17, 2009 read the sticky. Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-958823 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... Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-958830 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()? Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-958833 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. Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-958838 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... Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-958844 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> Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-958846 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... Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-958853 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? Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-958861 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? Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-958877 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 Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-958878 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 Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-958886 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? Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-959266 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. Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-959273 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'"); Link to comment https://forums.phpfreaks.com/topic/181806-solved-header-confusion/#findComment-959282 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.