Hello, help a newbie.
There is a form of filling data. How to send a user to another page if the registration was successful?
<form action="<?=$_SERVER['PHP_SELF'];?>" method="POST"> Введите логин: <br> <input type="text" name="login"><br> Введите пароль:<br> <input type="text" name="pas"><br> Подтвердите пароль:<br> <input type="text" name="pas_clear"><br> <input type="submit" value="Зарегистрироваться"> </form>
and the code that processes the form and puts the data into the database:
<?php ////////////////////////////////////////////// // 1.Проверка правильности заполнения формы // ////////////////////////////////////////////// if($_SERVER['REQUEST_METHOD']=="POST"){ $login = trim($_POST['login']); $pas = trim($_POST['pas']); $pas_clear = trim($_POST['pas_clear']); if (!empty($login) && !empty($pas) && !empty($pas_clear) && $pas==$pas_clear){ ///////////////////////////////////////////////////// // 2. Проверка на наличия уже существования логина // ///////////////////////////////////////////////////// //подключение к базе данных include "blocks/db.php"; $usr = mysql_query("SELECT COUNT(*) FROM user WHERE login = '$login'"); $total = mysql_result($usr, 0); if($total > 0){ exit("Данные логин уже зарегистрирован, пожалуйста, выберите другой."); }elseif($total == 0){ ////////////////////////////////////////////////////////////////// // 3. Регистрируем и заносим в базу логин и пароль пользователя // ////////////////////////////////////////////////////////////////// $usr = "INSERT INTO user VALUES (NULL, '$login', '$pas')"; if (mysql_query($usr)) { echo "</H3>Регистрация прошла успешно</H3>"; echo "<p>Ваш логин: ".$login."\n<br> Ваш пароль: ".$pas."\n<br>Запомните свои данные, а лучше запишите.</p>"; }elseif(!$usr){ exit ("Ошибка при добавлении данных - ".mysql_error()); } } } ?>
Actually the question is how can you make it so that if everything is entered correctly by the user, then this
echo "</H3>Регистрация прошла успешно</H3>"; echo "<p>Ваш логин: ".$login."\n<br> Ваш пароль: ".$pas."\n<br>Запомните свои данные, а лучше запишите.</p>";`
It was displayed on another page without a form, but in case of an error, for example, the password does not match, then output information about it on the same page? The handler on my page is where the form <form action="<?=$_SERVER['PHP_SELF'];?>" method="POST">
Help, please, with an explanation, I will be deeply grateful to all of you. Do not look at security, just writing a function for this.