Advertisement
Nikita051

Untitled

Aug 20th, 2022
1,470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.66 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     if(empty($pr)){
  4.     if(isset($_GET['login']) && isset($_GET['password']) && $_GET['password'] == $_GET['confirm']){                    
  5.         header("Location: index.php");
  6.      }};
  7. ?>
  8. <form action = "" method = "GET">
  9.     <input name="login" placeholder="Login"></br>
  10.     <input type="password" name="password" placeholder="Password"></br>
  11.     <input type="password" name="confirm" placeholder="Confirm pass"></br>
  12.     <input type="date" name="date" placeholder="Birthday"></br>
  13.     <input type="email" name="email" placeholder="Email"></br>
  14.     <input type="submit">
  15. </form>
  16. <?php
  17.     $host = "localhost";
  18.     $user = "root";
  19.     $pass = "root";
  20.     $name = "test";
  21.     $link = mysqli_connect($host,$user,$pass,$name);
  22.  
  23.     if (!empty($_GET['login']) and !empty($_GET['password']) and $_GET['password'] == $_GET['confirm']){
  24.         $conf = $_GET['confirm'];
  25.         $login = $_GET['login'];
  26.         $pass = $_GET['password'];
  27.         $email = $_GET['email'];
  28.         $birt = $_GET['date'];
  29.         $today = date('Y-m-d');
  30.         $qu = "SELECT * FROM users WHERE login='$login'";
  31.         $res = mysqli_query($link,$qu);
  32.         $pr = mysqli_fetch_assoc($res);
  33.         if(empty($pr)){
  34.             $query = "INSERT INTO users SET login='$login',password='$pass',Email='$email',birthday='$birt',today='$today'";
  35.             $_SESSION['auto'] = true;
  36.             mysqli_query($link,$query);
  37.             $id = mysqli_insert_id($link);
  38.             $_SESSION['id'] = $id;
  39.             } else {
  40.             echo "Логин занят";
  41.         }
  42.      } else {
  43.          echo "Пароли не совпдаюат";
  44.      }  
  45. ?>
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement