标签: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 !‘;
}
标签:rgb htm echo mysq style failed rgba 案例 connect
原文地址:https://www.cnblogs.com/dissipate/p/14639539.html