码迷,mamicode.com
首页 > Web开发 > 详细

前端php测试案例

时间:2021-04-10 13:29:04      阅读:0      评论:0      收藏:0      [点我收藏+]

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

  

 

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

 

 

<?php
    // var_dump($_GET);
    echo <br/>;
    $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 <br/>;
    $data=mysqli_fetch_all($result,MYSQLI_ASSOC);
    echo count($data);
    echo <br/>;
    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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!