前端php测试案例

2021-05-31 17:01

阅读:429

标签:rgb   htm   echo   mysq   style   failed   rgba   案例   connect   

  

 

php
    session_start();
    // $_SESSION[‘login‘]=11;
    echo $_SESSION[login];
?>

 

 

php
    // var_dump($_GET);
    echo 
; $username=$_GET[username]; $password=$_GET[password]; $link=mysqli_connect(localhost,root,cruces,abate); $sql="select * from users where username=‘$username‘ and password=‘$password‘"; $result=mysqli_query($link,$sql); // print_r($result); echo
; $data=mysqli_fetch_all($result,MYSQLI_ASSOC); echo count($data); echo
; if(count($data)){ header(location: ./home.html); }else{ echo login failed; } ?>

 

 

login:

 

php
  $username=$_POST[username];
  $password=$_POST[password];
  $link=mysqli_connect(localhost,root,cruces,abate);
  $sql="select * from `users` where username=‘$username‘ and password=‘$password‘";
  $result=mysqli_query($link,$sql);
  $data=mysqli_fetch_all($result,MYSQLI_ASSOC);
  if(count($data)){
    session_start();
    $_SESSION[login]=11;
    $_SESSION[username]=$data[0][username];
    header(location: ./index.php);
    var_dump($data);
  }else{
    echo failed !;
  }

 

前端php测试案例

标签:rgb   htm   echo   mysq   style   failed   rgba   案例   connect   

原文地址:https://www.cnblogs.com/dissipate/p/14639539.html


评论


亲,登录后才可以留言!