ok i have 4 different sets of coding here that is possibly the problem (from what little i know anyhow)
here is the register page
HTML Code:
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<form action="process_registration.php" method="post">
<p>username: <input name="username" size="13"></p>
<p>email: <input type="text" name="email" size="13"></p>
<p>confirm your email: <input type="text" name="cemail" size="13"></p>
<p>password: <input type="password" name="password" size="13"></p>
<p>confirm your password: <input type="password" name="cpassword" size="13"></p>
<input type="submit" name="Register" value="Register"> <input type="reset" name="Reset" value="Reset">
</form>
</body>
</html>
here is the registration php file
PHP Code:
<?php
require_once 'handler.php';
$username = cleanString($_POST['username']);
$password = $_POST['password'];
$cpassword = $_POST['cpassword'];
$email = cleanString($_POST['email']);
$cemail = cleanString($_POST['cemail']);
$errors = array();
$sql = mysql_query("SELECT * FROM users WHERE username = '$username'");
if(mysql_num_rows($sql) != 0){
$errors[] = "That username is already in use.";
}
if($password != $cpassword){
$errors[] = "Your passwords do not match.";
}
if($email != $cemail){
$errors[] = "Your email addresses do not match.";
}
if(strlen($password) > 16 || strlen($password) < 6){
$errors[] = "Your password must be between 6 and 16 characters. All characters are allowed.";
}
if(!preg_match("/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i", $email)){
$errors[] = "You need to enter a valid e-mail address.";
}
if(count($errors) > 0){
echo 'There were some problems with submitting your registration:<br /><ul>';
foreach($errors as $error){
echo '<li>' . $error . '</li>';
echo"<META HTTP-EQUIV=\"Refresh\" Content=\"10;URL=register.html\">\n";
}
echo '</ul>';
}
else{
mysql_query("INSERT INTO b18_4043037_users.users (username, password, email) VALUES ('$username', '" . md5($password) . "', '$email')");
echo 'You have successfully registered. You can now log in.';
echo"<META HTTP-EQUIV=\"Refresh\" Content=\"5;URL=login.html\">\n";
}
?>
the sign in page is as follows
HTML Code:
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<form action="login.php" method="post">
<p>username: <input type="text" name="username" size="13"></p>
<p>password: <input type="password" name="password" size="13"></p>
<input type="submit" name="Login" value="Login"> <input type="reset" name="Reset" value="Reset">
</form>
Not registered then click <a href="register.html">here</a> to register
</body>
</html>
and the login.php is
PHP Code:
<?php
require_once 'handler.php';
$username = cleanString($_POST['username']);
$password = md5($_POST['password']);
if(empty($username) || empty($password)){
echo 'You must enter a username and password!';
echo"<META HTTP-EQUIV=\"Refresh\" Content=\"5;URL=login.html\">\n";
}
else{
$sql = mysql_query("SELECT * FROM users WHERE username='$username'");
if(mysql_num_rows($sql) < 1){
echo 'That username does not exist.';
echo"<META HTTP-EQUIV=\"Refresh\" Content=\"5;URL=login.html\">\n";
}
else{
$sql2 = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");
if(mysql_num_rows($sql2) < 1){
echo 'Your password is incorrect.';
echo"<META HTTP-EQUIV=\"Refresh\" Content=\"5;URL=login.html\">\n";
}
else{
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
echo"<META HTTP-EQUIV=\"Refresh\" Content=\"5;URL=index2.php\">\n";
}
}
}
?>
if anyone could telll me why i keep getting "Your password is incorrect. " when i try to log in
if any more info is needed to help resolve this issue let me know
thanks