V
V
vermalen2018-07-05 20:32:36
PHP
vermalen, 2018-07-05 20:32:36

Why doesn't the password change function work?

I can't figure out what's wrong here, when I enter static data for example: "SET `password` = '123' " everything changes, and when I try to display data from the form, nothing changes (Here is the code:

<?php
$password = $_POST['password'];
$login = $_POST['login'];
$mysqli = new mysqli("localhost","root","","registration3")or die("Нет соединения: " . mysql_error());
print ("Удачно соединено");;
$mysqli->query("SET NAMES 'utf8' ");


//$result = mysql_query ("UPDATE `users` SET `password` = $password WHERE `users`.`login` = $login;");
$result = $mysqli->query("UPDATE `users` SET `password` = '$password' WHERE `users`.`login` = '$login';");
$mysqli->close();

?>
<a href="index.php" style="color:blue"  >Назад</a>
<h1>Восстановление пароля</h1>
<form action="change.php" method="POST" >
  <input type="text" name="login" placeholder="Введите логин" >
  <input type="password" name="password"  placeholder="Введите пароль"   >
  
  <button type="submit" name="do_change">Отправить</button>
</form>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ambrel, 2018-07-05
@Ambrel

$result = $mysqli->query(' UPDATE `users` SET `password` = ' . $password . ' WHERE `login` = ' . $login);
$mysqli->close();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question