I've made in MySql a Database (members) and 1 table (users)
and 2 Fields in it:
1. username - varchar(30)
2. password - varchar(30)
In Php I've made: Register.php, login.php, members.php, logout.php.
Everything is alright it works, but when i Register whit a name example: John
password: 12345
It says registered successfully, but when i try to login whit "John" & "12345" It says: "Incorrect Password".
The username and the password has entered the database but the passoword is something like this: 0c10749e230a74b09c6b0e7af.
I've tried whit this password too but it hasn't work.
So The Main Problem is that the password don't enters the database correctly or i don't know...
REGISTER.PHP:
<?php
// Connects to your Database
mysql_connect("localhost", "xy_admin", "xyz") or die(mysql_error());
mysql_select_db("xy_members") or die(mysql_error());
//This code runs if the form has been submitted
if (isset($_POST['submit'])) {
//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
die('Kérem töltsön ki minden mezõt!
<a href=register.php>vissza</a>');
}
// checks if the username is in use
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
//if the name exists it gives an error
if ($check2 != 0) {
die('Sajnos a(z) '.$_POST['username'].' név már foglalt, kérem válasszon egy másik nevet.
<a href=register.php>vissza</a>');
}
// this makes sure both passwords entered match
if ($_POST['pass'] != $_POST['pass2']) {
die('A jelszavak nem egyeznek, kérem ÃÂrja be ujból.
<a href=register.php>vissza</a>');
}
// here we encrypt the password and add slashes if needed
$_POST['pass'] = md5($_POST['pass']);
if (!get_magic_quotes_gpc()) {
$_POST['pass'] = addslashes($_POST['pass']);
$_POST['username'] = addslashes($_POST['username']);
}
// now we insert it into the database
$insert = "INSERT INTO users (username, password)
VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
$add_member = mysql_query($insert);
?>
<h1>Sikeres regisztrácio!</h1>
<p>Köszönjük, hogy regisztrált, most már <a href=login.php>bejelentkezhet</a>.</p>
<?php
}
else
{
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border="0">
<tr><td>Név:</td><td>
<input type="text" name="username" maxlength="60">
</td></tr>
<tr><td>Jelszó:</td><td>
<input type="password" name="pass" maxlength="10">
</td></tr>
<tr><td>Jelszó ujra:</td><td>
<input type="password" name="pass2" maxlength="10">
</td></tr>
<tr><th colspan=2><input type="submit" name="submit" value="Regisztrálás"></th></tr> </table>
</form>
<?php
}
?>
Or the Problem is in the LOGIN.PHP???
Tags: