关于mysql数据库的调用
做的是一个通讯录管理系统,登录界面输入账号和密码过后登录就会显示这个文件的源代码,好像是没能运行,请问怎么修改。conn文件应该没问题的。谢谢大家<?phpinclude...
做的是一个通讯录管理系统,登录界面输入账号和密码过后登录就会显示这个文件的源代码,好像是没能运行,请问怎么修改 。conn文件应该没问题的。谢谢大家
<?php
include_once('../inc/conn.php');
session_start();
$name=$_POST["username"];
$password=$_POST["password"];
$sql="SELECT * FROM users WHERE username='$name' and password ='$password' ";
//echo $sql;
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if($row){
$uname=$row['username'];
$pwd=$row['password'];
$qxian=$row['quanxian'];
if($name== $uname && $password=$pwd){
$_SESSION['name'] = $uname;
$_SESSION['islogin']=1;
if($qxian==1){
echo "<script>alert('恭喜你,登陆成功!');location.href='../main.php';</script>";
}else{
echo "<script>alert('恭喜你,登陆成功!');location.href='../adressList.php';</script>";
}
}
}else {
echo "<script>alert('登陆失败,请检查密码是否正确!');location.href='../index.php';</script>";
}
?> 展开
<?php
include_once('../inc/conn.php');
session_start();
$name=$_POST["username"];
$password=$_POST["password"];
$sql="SELECT * FROM users WHERE username='$name' and password ='$password' ";
//echo $sql;
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if($row){
$uname=$row['username'];
$pwd=$row['password'];
$qxian=$row['quanxian'];
if($name== $uname && $password=$pwd){
$_SESSION['name'] = $uname;
$_SESSION['islogin']=1;
if($qxian==1){
echo "<script>alert('恭喜你,登陆成功!');location.href='../main.php';</script>";
}else{
echo "<script>alert('恭喜你,登陆成功!');location.href='../adressList.php';</script>";
}
}
}else {
echo "<script>alert('登陆失败,请检查密码是否正确!');location.href='../index.php';</script>";
}
?> 展开
2个回答
展开全部
//整理了一下代码,改了一个地方:
<?php
include_once('../inc/conn.php');
session_start();
$name=$_POST["username"];
$password=$_POST["password"];
$sql="SELECT * FROM users WHERE username='$name' and password ='$password' ";
//echo $sql;
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if($row){
$uname=$row['username'];
$pwd=$row['password'];
$qxian=$row['quanxian'];
if($name== $uname && $password==$pwd){ //这一行第二个等号是双等号
$_SESSION['name'] = $uname;
$_SESSION['islogin']=1;
if($qxian==1){
echo "<script>alert('恭喜你,登陆成功!');location.href='../main.php';</script>";
}else{
echo "<script>alert('恭喜你,登陆成功!');location.href='../adressList.php';</script>";
}
}
}else {
echo "<script>alert('登陆失败,请检查密码是否正确!');location.href='../index.php';</script>";
}
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询