Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mmmdreg

macrumors 65816
Original poster
Apr 14, 2002
1,393
0
Sydney, Australia
The following is nearly pretty much copied out of a book.. yet the user variable is blank. IE, in the second file, "echo $_Post['user'];" outputs nothing even though I inputted something. Am I doing something wrong?

George

Code:
<?php
	session_unset();
?>
<html>
	<head>
		<title>Please Log In</title>
	</head>
	<body>
		<form method="post" action="page2.php">
			<p>Enter your username:
				<input type="text" name="user">
			</p>
			<p>
				<input type="submit" name="Submit" value="Submit">
			</p>
	</body>
</html>

Code:
<?php
	session_start();
	$_SESSION['username'] = $_Post['user'];
	$_SESSION['authuser'] = 0;
	
	if ($_SESSION['username'] == 'George') {
		$_SESSION['authuser'] = 1;
	} else {
		echo "Sorry, no permission";
		echo $_Post['user'];
		exit();
	}
?>
<html>
<head>
<title>Title</title>
</head>
<body>
<?php
	echo "Welcome";
?>
</body>
</html>
 

LtRammstein

macrumors 6502a
Jun 20, 2006
570
0
Denver, CO
Don't forget to post in the PROPER FORUM! PHP is web-based, so it should be in the Web Development forum.

Just a little FYI. ;)

Steve
 

SC68Cal

macrumors 68000
Feb 23, 2006
1,642
0
I'm fairly certain that you need to call the session_start(); function at the top of the first page in order to use the session array.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.