I created the database "anastasiya" with the table "users".
When a user registers on the site, nothing is recorded in the "users" table. Check for count. characters "login" and "password" is successful. It does not give any errors.
Tell me, what could be wrong here?
Here is the code:
<?php if (isset($_POST['reg'])){ $login = $_POST['login']; $password = $_POST['password']; $bad=false; session_start(); unset ($_SESSION['error_login']); unset ($_SESSION['error_password']); unset ($_SESSION['reg_success']); if ((strlen($login) < 3) || (strlen($login) > 32)){ $_SESSION['error_login'] = 1; $bad=true; } if ((strlen($password) < 6) || (strlen($password) > 32)){ $_SESSION['error_password'] = 1; $bad=true; } if (!$bad){ $mysqli = new mysqli("localhost","root","","anastasiya"); $password = md5($password); $login = $mysqli->real_escape_string($login); $password = $mysqli->real_escape_string($password); $mysqli -> query("INSERT INTO users ('login','password')VALUES('$login','$password')"); $mysqli -> close(); $SESSION['reg_success'] = 1; header("Location: index.php"); } } ?>
commitmanually - andreymal'$login'and'$password'instead of the ones entered by the user. Therefore, either use string concatenation, or see how to pass parameters in mysqli (unfortunately, I am not familiar with mysqli). - Aries