Hello. Data from the form is not sent to the users table. I use local Apache server and MySQL database (XAMPP). The table structure: user_id (AUTO_INCREMENT); login; password; name; email;
File register_html.php :
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/html"> <head> <meta charset="UTF-8"> <title>Страница регистрации</title> </head> <body> Заполните форму: <form method="post" action=""> Логин: <input type="text" name="login" required><br> E-Mail:<input type="email" name="email" required><br> Пароль:<input type="password" name="password" required><br> Имя:<input type="text" name="name" required><br> <input type="submit" name="enter" value="Регистрация"><br> <input type="reset" value="Очистить"><br> </form> <?php ini_set('display_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); include_once "../connect.php"; if (isset($_POST['enter'])) { $login = $_POST['login']; $email = $_POST['email']; $password = $_POST['password']; $name = $_POST['name']; $result = mysqli_query($link,"INSERT INTO `users` (`login`, `email`, `password`, `name`) VALUES ('".$login."', '".$email."', '".$password."', '".$name."')"); if($result){ echo 'Регистрация прошла успешно'; } else{ echo 'Ошибка'; // выводите ошибку } } echo mysqli_error($link); ?> File connect.php
<?php ini_set('display_errors',1); error_reporting(E_ALL); $link = mysqli_connect("localhost", "root", "", "mydb") or die("Unable to select database"); $db = mysqli_select_db($link,"mydb"); mysqli_query($link," SET NAMES 'utf8' "); if ($link->connect_errno) { echo "Не удалось подключиться к MySQL: (" . $link->connect_errno . ") " . $link->connect_error; } echo $link->host_info . "\n"; if (!$link || !$db){ exit(mysqli_error()); } ?> When entering data into a form and clicking the registration button, the form is simply updated to empty, no errors appear, just like the 'Registration was successful' registered in the script. If you simply execute the text request to the database without a form, everything is written into the table. Such a feeling that the problem is in the script of the form handler. Tell me please what can be the reason? Thanks in advance.
users(login,email,password,name) VALUES ('losdfdsf', 'msdfsdl@mail.ru', '123sdfqwe', 'mynasdfme')") with connection To the database, too, all data is recorded. - Dust0 2:51 pm