Answer the question
In order to leave comments, you need to log in
Another PHP code error for the day, help???
$connect = mysql_connect("localhost", "cj28778_bd", "1234567") or die(mysql_error());
mysql_select_db("cj28778_bd");
if(isset($_POST['submit'])){
$username = $_POST['username'];
$login = $_POST['login'];
$password = $_POST['password'];
$r_password = $_POST['r_password'];
}
if ($password == $r_password) {
$password = md5($password);
$query = mysql_query("INSERT INTO users VALUES('','$username', '$login', '$password')") or die(mysql_error());
}
else{
die("Пароли не совпадают");
}
if (isset($_POST['enter'])) {
$e_login = $_POST['e_login'];
$e_password = md5($_POST['e_password']);
$query = mysql_query("SELECT * FROM users WHERE login='$e_login'");
$user_data = mysql_fetch_array($query);
if ($user_data['password'] == $e_password) {
echo "Авторизация прошла успешно!";
}
else{
echo "Неверный пароль или логин";
}
}
Answer the question
In order to leave comments, you need to log in
check echo'm the $e_password variable after md5. I think she's the problem. (perhaps it is empty at all) (or $e_login is empty)
p.s. Maybe the password is too long? do you have a password in mysql with a length of 26 and hashing - does not fit (respectively cuts off)?
1. Escape the SQL parameters. Your site is already one big hole - you can do anything with the database.
2. Debugging is for wimps?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question