Advertisement
george-goga

auth.php

Sep 10th, 2022 (edited)
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.37 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include("connectbd.php");
  4.  
  5. $_SESSION["login"];
  6. $_SESSION["password"];
  7.  
  8. $login=$_POST["login"];
  9. $password=$_POST["password"];
  10. $email=$_POST["email"];
  11.  
  12. $aselect="SELECT * FROM User WHERE ('login'='$login' AND 'password'='$password')";
  13. $aresult=mysqli_query($connect, $aselect)or die(mysqli_error($connect));
  14.  
  15.  function ver(){
  16.     if(empty($_SESSION["login"]&&$_SESSION["password"])){
  17.     authoriz();
  18.      reg();
  19.  echo"<form name=\"aitorization\" action=\"#\" method=\"POST\">".
  20. "<input type=\"text\" name=\"login\">".
  21. "<input type=\"password\" name=\"password\">".
  22. "<input type=\"submit\" name=\"in\" value=\"Вход\">".
  23. "<input type=\"submit\" name=\"reg\" value=\"Регистрация\">".
  24. "</form>";
  25.     }else{
  26.     echo $_SESSION["login"];
  27.      out();
  28.      echo"<form name=\"out\" action=\"#\" method=\"POST\">"."<input type=\"submit\" name=\"out\" value=\"выход\">"."</form>";
  29.     }
  30.     }
  31.  
  32.  function authoriz(){
  33.  if(isset($_POST["in"])){
  34.     if(!empty($_POST['login']&&$_POST['password'])){
  35.     var_dump($_POST);
  36.     if(mysqli_num_rows($aresult)==1){
  37.     $_SESSION["login"]=$_POST["login"] ;
  38.      $_SESSION["password"]=$_POST["password"];
  39.      echo"hh";
  40.      }
  41.      }
  42.      }
  43.     }
  44.    
  45.  function reg(){
  46.     if($_POST["reg"]){
  47.     header("Location:../reg.php");
  48.  }
  49. }
  50.  
  51.  function out(){
  52.  if($_POST["out"]){
  53.     session_unset();
  54.     }
  55.  }
  56.  ver();
  57. ?>
Tags: Au.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement