Well.. I am getting an Undefined index notice from the Log-In code below.
I have not written the code myself, so I guess the problem is that I am not sure what "op" is exactly.
Can someone please provide me with some input on what I need to do in order to get rid of the 'Undefined index' notice?
Quote:
|
Notice: Undefined index: op in C:\program files\apache\htdocs\login.php on line 6
|
PHP Code:
<?php
session_start();
$conn = mysql_connect("localhost","hat","pas");
$db = mysql_select_db("database");
if ($_GET["op"] == "login")
{
$username = $_POST["username"];
$password = $_POST["password"];
if (!$username || !$password)
{
die("You need to supply a username and password.");
}
$result = MYSQL_QUERY("SELECT * from users WHERE username='$username'and password=PASSWORD('$password')")
or die ("Name and password not found or not matched");
$worked = mysql_fetch_array($result);
$id = $worked['id'];
$_SESSION["valid_id"] = $id;
$_SESSION["valid_user"] = $username;
$_SESSION["valid_time"] = time();
// Redirect to member page
Header("Location: members.php");
}
else
{
echo "<form action=\"?op=login\" method=\"POST\">";
echo "Username: <input name=\"username\" size=\"15\"><br />";
echo "Password: <input type=\"password\" name=\"password\" size=\"8\"><br />";
echo "<input type=\"submit\" value=\"Login\">";
echo "</form>";
}
?>
|