Answer the question
In order to leave comments, you need to log in
How to redirect after successful registration?
There are three pages index.php, register.php and poup.php
register.php
<?php include_once 'poup.php'; ?>
<div id="content">
<form method="post" action="" id="formregistr">
<input type="text" name="username" placeholder=" Имя Пользователя" contextmenu="" minlength="4" required=""><p />
<input type="text" name="login" placeholder=" Логин" minlength="4" required=""><p />
<input type="password" name="password" placeholder=" Пароль" minlength="2" required><p />
<input type="password" name="r_password" placeholder=" Подтверждение Пароля" minlength="2" required=""><p />
<input type="submit" name="submit" value="Регистрация"><p />
<?php echo $a_not_error; ?>
<?php echo $a_error; ?>
<?php echo $a_error_duble; ?>
<?php echo $a_error_lang; ?>
</form>
</div>
<?php include_once 'header.php'; ?>
<?php
$connect = mysql_connect('localhost', 'root', '') or die(mysql_error());
mysql_select_db('test');
if(isset($_POST['submit'])) {
$username = $_POST['username'];
$login = $_POST['login'];
if(preg_match("/[^A-Za-z0-9_-]/u", $_POST['login'])) {
$a_error_lang = "Только латинские буквы и цифры";
return include_once 'registr.php';
}
$password = $_POST['password'];
$r_password = $_POST['r_password'];
$result = mysql_query("SELECT id FROM registr WHERE login='$login'");
$user_duble = mysql_fetch_array($result);
if ($user_duble == TRUE) {
$a_error_duble = 'Пользователь с таким логином зарегистрирован';
return include_once 'registr.php';
}
if($password == $r_password) {
$password = md5($password);
$result_2 = mysql_query("INSERT INTO registr VALUES('id',
'$username','$login','$password')") or die(mysql_error());
$a_not_error = "Вы успешно зарегистрировались!";
}
else $a_error = "Несовпадение паролей";
}
?>
Answer the question
In order to leave comments, you need to log in
<?php if (!empty($a_not_error)) { ?>
<p>Вы успешно зарегистрировались! Через 5 секунд будет произведено перенаправление на главную страницу</p>
<script> window.setTimeout(function() { window.location = 'index.php'; }, 5000) </script>
<?php } ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question