Jump to content

[SOLVED] head scratcher


tronicsmasta

Recommended Posts

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

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.