Issue
if(isset($_POST["email"]))
{
$email = mysql_real_escape_string($_POST["email"]); /* Line 10 */
$password = mysql_real_escape_string($_POST["password"]);
$result = mysql_query("SELECT password, id FROM users WHERE email = '$email'");
if (!$result)
{
die('Invalid query: ' . mysql_error());
}
$row = mysql_fetch_assoc($result);
if($row['password'] == $password)
{
ini_set("session.cookie_lifetime","360000");
session_start();
$_SESSION['valid_user'] = $row['id'];
$_SESSION['email'] = $row['email'];
mysql_close($link);
header('Location: index.php');
}
mysql_close($link);
}
I'm not making any posts but it says that $email
is not defined at line 10. Why? I use EasyPHP.
Notice: Undefined index: email in C:\Program Files\EasyPHP-5.3.5.0\www\v0.3\model\login.php on line 10
Solution
The most reliable method for checking if a POST was done is via
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
... you're in a post ...
}
Checking for a particular form field is risky - you might rename/delete the field and forget to update the form. But checking for that $_SERVER value is 100% reliable - it's always available, regardless of what method the script was invoked via.
Answered By - Marc B Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.