tronicsmasta Posted May 9, 2008 Share Posted May 9, 2008 hey guys, I restored my server today and reuploaded my files for a mistake i made... now sessions don't work any more if ($_POST['username'] == $username && $_POST['password'] == $password) { $_SESSION[valid] = "yes"; header( "Location: http://marcello.oddoesit.com/main.html"); exit(); } else { $prompt .= "Authentication Failed!<br>"; } error that PHP outputs is Notice: Use of undefined constant valid - assumed 'valid' in /var/www/vhosts/oddoesit.com/subdomains/marcello/httpdocs/index.php on line 21 Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/oddoesit.com/subdomains/marcello/httpdocs/index.php:21) in /var/www/vhosts/oddoesit.com/subdomains/marcello/httpdocs/index.php on line 22 any idea's? Link to comment https://forums.phpfreaks.com/topic/104898-solved-head-scratcher/ Share on other sites More sharing options...
BlueSkyIS Posted May 9, 2008 Share Posted May 9, 2008 you had notices turned off, now they are turned on, giving you that Notice, which in turn causes the Header error. Link to comment https://forums.phpfreaks.com/topic/104898-solved-head-scratcher/#findComment-536859 Share on other sites More sharing options...
tronicsmasta Posted May 9, 2008 Author Share Posted May 9, 2008 I turned on notices because the sessions arent working anymore... for example at the top of each page is session_start(); if ($_SESSION[valid] != "yes") { header("Location: http://marcello.oddoesit.com/"); exit(); } ?> so i turned on error reporting to find out why i wasnt being redirected and now im in a bind... grr thanks, quinton Link to comment https://forums.phpfreaks.com/topic/104898-solved-head-scratcher/#findComment-536864 Share on other sites More sharing options...
obsidian Posted May 9, 2008 Share Posted May 9, 2008 you had notices turned off, now they are turned on, giving you that Notice, which in turn causes the Header error. Correct. As soon as something is output to the browser, headers have been sent. What you need to do is wrap the "valid" key in your $_SESSION call in quotes to avoid the notice, and things should behave properly. Link to comment https://forums.phpfreaks.com/topic/104898-solved-head-scratcher/#findComment-536865 Share on other sites More sharing options...
tronicsmasta Posted May 9, 2008 Author Share Posted May 9, 2008 turned off error reporting and did as you suggested... still no redirect <? session_start(); if ($_SESSION["valid"] != "yes") { header("Location: http://marcello.oddoesit.com/"); exit(); } ?> Link to comment https://forums.phpfreaks.com/topic/104898-solved-head-scratcher/#findComment-536867 Share on other sites More sharing options...
BlueSkyIS Posted May 9, 2008 Share Posted May 9, 2008 i wouldn't turn off any error reporting. i would fix the problems as they are reported. Link to comment https://forums.phpfreaks.com/topic/104898-solved-head-scratcher/#findComment-536872 Share on other sites More sharing options...
tronicsmasta Posted May 9, 2008 Author Share Posted May 9, 2008 lmao hey guys... yea... so before i made this backup, i added to the httpd.conf file to parse php in html files also... hehe AddType application/x-httpd-php .php .html Link to comment https://forums.phpfreaks.com/topic/104898-solved-head-scratcher/#findComment-536888 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.