Encountered the MySQL problem again. My whole login form is screwed and I cannot cope with it anymore. Help is apreciated very much.
That's my whole sign in verification script. Obviously a form gets posted to this script with two text fields 'username' and 'password'. I cannot login. Or when I can, it lets me log in with any password. It's very screwed up but this is my last resort. If you guys cannot help me, I'm packing the whole thing in....Thanks
PHP:
<?php
session_start();
include("config.php");
$passwordbeforemd5=$_POST['password'];
$username=$_POST['username'];
$password=md5('$passwordbeforemd5');
$query = "SELECT * FROM users WHERE username='$username' AND password='$password'" or die(mysql_error());
$id = mysql_result($query,0,"id");
$account = mysql_result($query,0,"account");
//$username=!isset($_SESSION['username'];
//$password=!isset($_SESSION['password'];
// Registering the variables uname and pwd
session_register("username","password","id", "account");
//Check user exists in database
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");
//Using mysql_num_rows we count the number of rows matching username and password which should be 1 if true and 0 if false
$login_check = mysql_num_rows($sql);
if ($login_check == "1") {
$_SESSION['logged_in'] = true;
include ("membersarea.php");
}
else {
include("head.php");
session_unset();
echo "<h1>Error</h1><p>Your attempt at logging in failed. If you feel as if there is
a problem, email the administrator at [email protected] or use the contact form</p>";
include("foot.php");
}
?>
That's my whole sign in verification script. Obviously a form gets posted to this script with two text fields 'username' and 'password'. I cannot login. Or when I can, it lets me log in with any password. It's very screwed up but this is my last resort. If you guys cannot help me, I'm packing the whole thing in....Thanks








