看了半天 这不是和《十天学会php》是相同的例子嘛! MD 这不是戏弄姐姐吗
login.php


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

checklogin.php
checklogin.php

<?
require_once('conn.php');
session_start();
$username=$_POST['username'];
$password=$_POST['password'];
$exec="select * from admin where username='".$username."'";
if($result=mysql_query($exec))
{
if($rs=mysql_fetch_object($result))
{
if($rs->password==$password)
{
$_SESSION['adminname']=$username;
header("location:index.php");
}
else
{
echo "<script>alert('Password Check Error!');location.href='login.php';</script>";
}
}
else
{
echo "<script>alert('Username Check Error!');location.href='login.php';</script>";
}
}
else
{
echo "<script>alert('Database Connection Error!');location.href='login.php';</script>";
}
?>
总感觉这里面有个东西要改,但是不知道是什么地方要改!


1

2

3

4

这里的第二行本来是$conn=mysql_connect ("127.0.0.1", "", ""); 但是我在本地有个shop的数据库;我就把用户名和密码都改成和我的phpMyAdmin的一样了 结果还是一样的令人崩溃!