Saturday, 19 November 2016

php - Undefined index in $_POST[...]

When I run the following code, I get this error:



Notice: Undefined index: user in C:\wamp\www\moviel.php on line 3


And also this:



Notice: Undefined index: pass in C:\wamp\www\moviel.php on line 4



I can't find the mistake. Where is the problem?



session_start();
$_SESSION['username'] = $_POST['user']; // <- LINE 3
$_SESSION['userpass'] = $_POST['pass']; // <- LINE 4
$_SESSION['authuser'] = 0;
// Check username and password information
if(($_SESSION['username'] == 'Joe')and

($_SESSION ['userpass'] == '12345')){
$_SESSION['authuser'] = 1;
}else{
echo "Sorry, but youd don`t have the permission to view this page, you loser!";
exit();
}
?>


Find My Favorite Movie!



?>
$myfavmovie = urlencode("Life of Brian");
echo "";
echo "Click here to see information about my favorite movie!";
echo "
";
echo "
";

echo "";
echo "Click here to see my top 5 movies.";
echo "
";
echo "echo "";
echo "Click here to see my top 10 movies"
?>


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...