Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'db.php';
- $login = $_POST['login'];
- $password = $_POST['password'];
- $data = $_POST;
- $errors = array();
- if( isset($data['go']) ){
- if( trim($data['login']) == '' )
- {
- $errors[] = 'Введите ваш логин!';
- }
- if( trim($data['email']) == '' )
- {
- $errors[] = 'Введите ваш Email!';
- }
- if( $data['password'] == '' )
- {
- $errors[] = 'Введите ваш пароль!';
- }
- if( empty($errors) )
- {
- ///Всё хорошо регаем user
- $reg = mysqli_query($connection,"INSERT INTO `users` `login` WHERE '$login' AND `password` WHERE '$password'");
- }else {
- echo '<div style="color: red;">'.array_shift($errors).'</div><hr>';
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Работа с формами PHP</title>
- </head>
- <body>
- <form action="/index.php" method="POST">
- <p>
- <p><strong>Ваш логин</strong></p>
- <input type="text" name="login">
- </p>
- <p>
- <p><strong>Ваш Email</strong></p>
- <input type="email" name="email">
- </p>
- <p>
- <p><strong>Ваш пароль</strong></p>
- <input type="password" name="password">
- </p>
- <p>
- <button type="submit" name="go">Зарегистрироваться</button>
- </p>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment