Created
January 13, 2016 12:10
-
-
Save VictorFursa/8a70525850c20586c01e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header("Content-Type: text/html; charset=utf-8"); | |
$connect = mysql_connect('localhost', 'root', '') | |
or die('Не удалось соединиться: ' . mysql_error()); | |
mysql_select_db('alcoholic') or die('Не удалось выбрать базу данных'); | |
mysql_set_charset("utf8"); | |
if(isset ($_POST["submit"])) { | |
if(isset($_POST["yes"])){ | |
$userName = $_POST["userName"]; | |
$login = $_POST["login"]; | |
$email = $_POST["email"]; | |
$password = $_POST["password"]; | |
$r_password = $_POST["r_password"]; | |
$age = $_POST["age"]; | |
if($password == $r_password){ | |
$password = md5($password); | |
$result = mysql_query("SELECT * FROM registration "); | |
while ($res = mysql_fetch_array($result)){ | |
if($res["email"] == $email or $res["login"] == $login){ | |
die("<b style='color:red;'> такой логин или емайл уже зарегестрирован </b>"); | |
} | |
mysql_query("INSERT INTO registration(name,login,password,email,age) | |
VALUES('$userName' , '$login','$password' , '$email' , '$age') "); | |
} | |
die("<h1>Добро пожалывать $userName регистрация прошла успешно теперь вы можите использыать свой логин и пароль для <a href='login.php'>входа</a></h1>"); | |
} elseif($password != $r_password){ | |
$not = "Пароли несовподают!"; | |
} | |
} elseif(!isset($_POST["yes"])){ | |
die( "<h1>В регистрации откзано так-как Вы не согласны с правилами</h1>"); | |
} | |
} | |
?> | |
<!DOCTYPE> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Регистрация на сайте</title> | |
<link href="css/style.css" rel="stylesheet" type="text/css"> | |
</head > | |
<body> | |
<div> | |
<form method="POST" action="registration.php"> | |
<b style="color:red">Имя :</b><input type="text" name="userName" placeholder="Имя" required><br> | |
<b style="color:red">Логин:</b><input type="text" name="login"placeholder="Логин" required><br> | |
<b style="color:red;">Email:</b><input type="email" name="email"placeholder="Email" required><br> | |
<b style="color:red;">Пароль:</b><input type="password" name="password"placeholder="****" required ><br> | |
<b style="color:red">Ещё раз пароль:</b><input type="password" name="r_password"placeholder="****" required><?php if(isset ($not)){ | |
echo "<b style='color: red'>".$not . "</b>"; } ?><br> | |
<b>Возраст:</b><input maxlength="2" size="2" type="text" name="age"><br> | |
<b>С <a href="rules.php">правилами</a> согласен</b> <input type="checkbox" name="yes"><br> | |
<input type="submit" name="submit" value="Отправить"> | |
</form> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment