Hi, i am creating a system which requires users to log in. This code does the job successfully:
<?php include("header.inc"); ?>
<h2>Login</h2>
<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
<table>
<tr><td>UserName:</td><td><input type="text" name="UserName"></td></tr>
<tr><td>Password:</td><td><input type="password" name="Password"></td></tr>
</table>
<input type="submit" name="login" value="Login">
</form>
<?php
if (isset($_POST) && $_POST['login'] == "Login") { //if the submit button is pressed...
//open db connection
//Database details
$server="localhost";
$dbusername="root";
$dbpassword="voBtGM";
$db_name="JobBase";
$connection = mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
$db = mysql_select_db($db_name, $connection) or die(mysql_error());
//select rows where username AND password match the posted values
$select = mysql_query("SELECT * FROM Members WHERE UserName = '".$_POST['UserName']."' AND Password = '".$_POST['Password']."'") or die(mysql_error());
//check that record exists
if (mysql_num_rows($select) != 1) {
echo ("Oops! Your username and password did not match our records!");
} else {.
$row = mysql_fetch_assoc($select);
if($row['Status'] == 1) { echo ("Meta redirect to the advertisers page here"); }
else { echo ("Meta redirect to the search page here"); }
}
//close db connection
mysql_close($connection);
}
?>
</body>
</html>
However, on loading the page i get the following error:
Notice: Undefined index: login in .......on line 14
Can anyone advise me on how to fix this??