This is driving me mad! For that 3 days ive checked the code for errors and it just dont work!
go to my web site, that i am doing for uni.
www.lsbuusedbookshop.co.uk
go to login. user name is 1234 and password 1234. i just says that that its incorrect , but the users in the DB. I duno what else to do , thought id ask people here the experts.
here the code... if any one can tell me why i be most greatful
<?php
session_start();
include "connect.inc.php";
if (isset($_POST['submit'])) {
$query = "SELECT student_Id, password FROM members " .
"WHERE student_Id = '" . $_POST['username'] . "' " .
"AND password = (PASSWORD('" . $_POST['password'] . "'))";
$result = mysql_query($query)
or die(mysql_error());
$row = mysql_fetch_array($result);
if (mysql_num_rows($result) == 1) {
$_SESSION['user_logged'] = $_POST['username'];
$_SESSION['user_password'] = $_POST['password'];
header ("Refresh: 5; URL=" . $_POST['redirect'] . "");
echo "You are being redirected to your original page request!<br>";
echo "(If your browser doesn't support this, " .
"<a href=\"" . $_POST['redirect']. "\">click here</a>)";
} else {
?>
<html>
<head>
<title>login_form</title>
</head>
<body>
<p>
Invalid Username and/or Password<br>
<form action="login_form.php" method="post">
<input type="hidden" name="redirect"
value="<?php echo $_POST['redirect']; ?>">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br><br>
<input type="submit" name="submit" value="submit">
</form>
</p>
</body>
</html>
<?php
}
} else {
if (isset($_GET['redirect'])) {
$redirect = $_GET['redirect'];
} else {
$redirect = "members.php";
}
?>
<html>
<head>
<title>Beginning PHP5, Apache and MySQL</title>
</head>
<body>
<p>
Login below by supplying your username/password...<br>
Or <a href="register.php">click here</a> to register.<br><br>
<form action="login_form.php" method="post">
<input type="hidden" name="redirect"
value="<?php echo $redirect; ?>">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br><br>
<input type="submit" name="submit" value="submit">
</form>
</p>
</body>
</html>
<?php
}
?>
Plese anyone can help me , the project is in very shortly !!!
Thanks Jon