Created
November 16, 2017 16:27
-
-
Save Oappot/47ca5e10cece1fcceadfc94b61a6f145 to your computer and use it in GitHub Desktop.
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<link rel="stylesheet" href="style.css"> | |
<meta charset="UTF-8"> | |
<title>test</title> | |
</head> | |
<body> | |
<div class="background"> | |
<div class="form"> | |
<button class="form__close-btn" onClick='showForm()'> | |
X | |
</button> | |
<form action='reg.php' method='POST' id="registration-form" class="form"> | |
<h2 class='form__heading'>Регистрация</h2> | |
<p>Придумайте логин:</p> | |
<input type="text" maxlength="20" name='login' required> | |
<p>Придумайте пароль:</p> | |
<input class='password' type="password" maxlength="20" name='password' required> | |
<p>Повторите пароль:</p> | |
<input class='password' type="password" maxlength="20" name='repeat-password' required> | |
<p class='error'> </p> | |
<button type='submit' onclick='validate()' class='form__accept-btn'>Подтвердить</button> | |
</form> | |
</div> | |
</div> | |
<header class="header"> | |
<div class="header__logo">orfarile</div> | |
<div class="header__buttons"> | |
<a href='#' class="header__btn">Вход</a> | |
<a href='#' class="header__btn" onClick='showForm()'>Регистрация</a> | |
</div> | |
</header> | |
<section class="content"> | |
<div class="content__slider"> | |
</div> | |
<div class="slider__circles"> | |
<div class="slider__circle"></div> | |
<div class="slider__circle"></div> | |
<div class="slider__circle"></div> | |
</div> | |
<a href="#" class="content__demo-test-btn">Демо-тест</a> | |
</section> | |
<footer class="footer"> | |
<a href="#" class="footer__item">Контакты</a> | |
<a href="#" class="footer__item">О нас</a> | |
<a href="#" class="footer__item">Нашли баг?</a> | |
<a href="#" class="footer__item">Отзывы</a> | |
</footer> | |
<script src='script.js'></script> | |
</body> | |
</html> |
This file contains 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 | |
$link = mysqli_connect ("orfarile.ow", "admin", "admin", "test") | |
or die ("Ошибка подключения"); | |
$result_login = mysqli_query($link, "SELECT login FROM users WHERE login = '".$_POST['login']."'") | |
or die ('Не удалось подключиться к базе'); | |
$result_login = mysqli_num_rows($result); | |
$result_password = mysqli_query($link, "SELECT password FROM users WHERE login = '".$_POST['password']."'") | |
or die ('Подключение не удалось'); | |
$result_password = mysqli_query($result_password); | |
if(isset($result_login) && isset($result_password)){ | |
header( 'Location: test/private-office.html', true, 303); | |
} | |
else { | |
echo 'login занят'; | |
} | |
mysqli_close($link); | |
?> |
This file contains 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 | |
$link = mysqli_connect ("orfarile.ow", "admin", "admin", "test") | |
or die ("Ошибка"); | |
$result = mysqli_query($link, "SELECT login FROM users WHERE login = '".$_POST['login']."'") | |
or die ('Не удалось подключиться к базе'); | |
$result = mysqli_num_rows($result); | |
if(!isset($result)){ | |
$sql = mysqli_query($link, "INSERT INTO users (login, password) | |
VALUES ('".htmlspecialchars($_POST['login'])."', '".htmlspecialchars($_POST['password'])."')"); | |
mysqli_close($link); | |
header( 'Location: test/private-office.htm', true, 303); | |
} | |
else { | |
echo 'login занят'; | |
} | |
?> |
This file contains 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
var show = false; | |
function showForm() { | |
if(show == false) { | |
document.getElementsByClassName('background')[0].style.display = 'flex'; | |
document.getElementById('registration-form').style.display = 'flex'; | |
show = true; | |
} else { | |
document.getElementsByClassName('background')[0].style.display = 'none'; | |
document.getElementsByClassName('error')[0].innerHTML = ''; | |
show = false; | |
} | |
} | |
function validate() { | |
password = document.getElementsByClassName('password'); | |
document.getElementsByClassName('error')[0].innerHTML = ''; | |
if (password[0].value != password[1].value) { | |
document.getElementsByClassName('error')[0].innerHTML = 'Пароли должны совпадать'; | |
// return false; | |
} else { | |
document.getElementById('registration-form').submit(); | |
// return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment