首先我要做的是检测用户名是否在数据库中!apmserv本地环境搭建,有一个bbs数据库,meassage表,表中有3个字段,分别是id user pass ;对应的值分别是 1 admin admin;类型分别是int(10) varchar(25) varchar(25);而本地共有3个php文件:
conn.php
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("bbs", $conn);
mysql_query("set names 'utf-8'"); //使用utf-8中文编码;
?>
register.php
login.php
include("conn.php");
if($_POST["submit"])
$name=$_POST['user'];
$sql="select * from message where user='".$name."'";
$result=mysql_query($sql) or die("账号不正确");
$num=mysql_num_rows($result);
if($num==0){
echo "帐号已存在";
}
?>
问题来了:无论我在register.php输入什么提交给login.php 都是显示帐号已存在,而且原本login.php文件就显示帐号已存在!我本想检测用户名是否在数据库中,却感觉调用不了数据库!!!哪里错了吗!!
回复讨论(解决方案)
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn