Forum Moderators: coopster

Message Too Old, No Replies

Undefined index notice

I have defined username, but script still returns notice.

         

max4

12:40 am on Apr 27, 2009 (gmt 0)

10+ Year Member



Hello,

I created the following login script based on Jatar's authentication thread. So far, I've run into an Undefined index notice, and no matter what I try the notice remains! I'm getting these notices:

Undefined index: username on line 12
Undefined index: userpass on line 13

This is the form action script:

<?php
session_start();

$con = mysql_connect("host","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("db", $con);

$username = $_POST["username"];
$userpass = md5($_POST["userpass"]);

$sql = "SELECT username , userpass FROM user WHERE username='$username' AND userpass='$userpass'";
$result = mysql_query($sql);
if (mysql_num_rows($result)!= 1) {
$loginError = 1;
include "login.php";
} else {

header("Location: profile.php");
}
?>

Any suggestions?

Thanks,
Max

eeek

1:37 am on Apr 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Undefined index: username on line 12
Undefined index: userpass on line 13

Obvious those fields are being posted by the web page that calls this script. Since you didn't include that page I can't tell you why.

max4

1:57 am on Apr 27, 2009 (gmt 0)

10+ Year Member



You know, I didn't even think of re-evaluating my login form. It's crazy what hours of frustration can make you forget. Of course those notices occurred, I didn't define username and userpass in the form.

It is fixed now. Thanks.