我的数据库的设置是像这样:
create database if not exists shop;
use shop;
create table if not exists users(
id serial primary key,
username varchar(20),
password char(20));
create table if not exists admins(
id serial primary key,
username varchar(20),
password char(20));
insert into admins values(null, 'admin', SHA('touch'));
,并与LOGIN_PROCESS页面存在我的主要问题。
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$db=mysqli_connect("localhost","root","","shop")or die(mysqli_error($db));
$q="select * from admins where username='$username' and password=SHA('$password')";
$results=mysqli_query($db, $q)or die(mysqli_error($db));
if(mysqli_num_rows($results) > 0)
{
session_start();
$_SESSION['username']=$username;
header("Location:index.php");
exit(0);
}
else
{
header("Location:login.php");
exit(0);
}
?>
当网页尝试验证的,而不是前往index.php的位置我的管理,它,而不是停留在login.php中,管理员凭据从未验证。同样的问题仍然存在于我的登录和注册过程页面及其各自的角色中。
您的代码对SQL注入开放! – Naruto
什么是SQL注入? – user3701521
有时你需要知道什么时候需要使用谷歌 – Naruto