I make the registration page in PHPStorm, the connection to the database is ok, but clicking on the button simply refreshes the page without issuing any messages. The variable in isset with the name of the button in the html match.
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <title>Register</title> </head> <body> <form method="POST" align="center"> New User?<br> Login <input name="login" type="text"/><br> Password <input name="password" type="password"/><br> <input name="submit" type="submit" value="Submit"/> </form> </body> </html> <?php // Страница регистрации нового пользователя # Соединямся с БД $link = mysqli_connect("localhost","root","") or die ("could not connect to mysql!"); mysqli_select_db($link,"yii") or die ("no database!"); $submit = $_POST['submit']; if(isset($submit)) { $err = array(); print 'good'; if (empty($_POST['login'])) { $err[] = "Введите логин"; } if (empty($_POST['password'])) { $err[] = "Введите пароль"; } # проверям логин if(!preg_match("/^[a-zA-Z0-9]+$/",$_POST['login'])) { $err[] = "Логин может состоять только из букв английского алфавита и цифр"; } if(strlen($_POST['login']) < 4 or strlen($_POST['login']) > 15) { $err[] = "Логин должен быть не меньше 4-х символов и не больше 15"; } # проверяем, не сущестует ли пользователя с таким именем $query = mysqli_query($link, "SELECT COUNT(id) FROM user WHERE username='".mysqli_real_escape_string($link, $_POST['login'])."'"); if(mysqli_num_rows($query) > 0) { $err[] = "Пользователь с таким логином уже существует"; } # Если нет ошибок, то добавляем в БД нового пользователя if(count($err) == 0) { $login = $_POST['login']; # Убераем лишние пробелы и делаем шифрование $password = md5(trim($_POST['password'])); mysqli_query($link,"INSERT INTO user SET username='".$login."', auth_key='".$password."'"); //header("Location: auth.php"); exit(); } else { print "<b>При регистрации произошли следующие ошибки:</b><br>"; foreach($err AS $error) { print $error."<br>"; } } } ?>
$submit = $_POST['submit'];var_dump($_POST)and see what you get - Anton Shchyrov