Hi People ... ok, I followed a tutorial on how to make a "Authroisation" page ... etc etc ... ok, it works, BUT i have two problems:
1) :::::
Notice: Undefined index: pass in C:\Documents and Settings\Joel A Taylor\My Documents\UI\OasisLA-new\login.php on line 5
Notice: Undefined index: user in C:\Documents and Settings\Joel A Taylor\My Documents\UI\OasisLA-new\login.php on line 5
Notice: Undefined index: user in C:\Documents and Settings\Joel A Taylor\My Documents\UI\OasisLA-new\login.php on line 8
Notice: Undefined index: pass in C:\Documents and Settings\Joel A Taylor\My Documents\UI\OasisLA-new\login.php on line 9
and
2) :::::
I'd like a succesful login to go to the "Staffedit" page, carring the StaffID of the person who's logged in. I know that bit should be too hard. I'm learning!!
thanks, here's my code:
<?php
require_once('Connections/connStaff.php');
mysql_select_db($database_connStaff, $connStaff);
$query_user = "SELECT count(StaffID) FROM staff WHERE password='$_POST[pass]' AND firstname='$_POST[user]'";
// Add slashes to the username, and make a md5 checksum of the password.
$_POST['user'] = addslashes($_POST['user']);
$_POST['pass'] = md5($_POST['pass']);
$result = mysql_query($query_user, $connStaff) or die(mysql_error());
$num = mysql_result($result, 0);
if (!$num) {
// When the query didn't return anything, display the login form.
echo "<h3>User Login</h3>
<form action='$_SERVER[PHP_SELF]' method='post'>
Username: <input type='text' name='user'><br>
Password: <input type='password' name='pass'><br><br>
<input type='submit' value='Login'>
</form>";
} else {
// Start the login session
session_start();
// We've already added slashes and MD5'd the password
$_SESSION['user'] = $_POST['user'];
$_SESSION['pass'] = $_POST['pass'];
// All output text below this line will be displayed
// to the users that are authenticated. Since no text
// has been output yet, you could also use redirect
// the user to the next page using the header() function.
// header('Location: page2.php');
header('Location: staffedit.php?StaffID=3');
echo "<h1>Congratulations</h1>";
echo "You're now logged in. Try visiting <a href='page2.php'>Page 2</a>.";
}
?>