php连接mysql的问题·
index_ok的代码<?phpsession_start();include("conn/conn.php");if($Submit==true){$query=mys...
index_ok的代码
<?php session_start();
include("conn/conn.php");
if($Submit==true){
$query=mysql_query("SELECT FROM user WHERE username='$username'",$link);
if(mysql_num_rows($query)>0){echo "该用户已经存在";
}else{
$querys ="INSERT INTO user(userid,username,address) VALUES('$userid','$username','$address')";
$result=mysql_query($querys);
if($result==true){
echo"gualiyuanzhucechengg";
}else{echo "注册失败";}}}
?>
conn/conn.php的代码
<?php
$link=mysql_connect('localhost','root','123456') or die('can not connect');;
mysql_select_db('kqwr',$link);
mysql_query("set names gb2312")
?>
index的代码
<body>
<table width="360" border="1">
<form name="form1" method="post" action="index_ok.php">
<tr>
<td height="40" colspan="3" align="center"><span class="STYLE1">管理员注册</span></td>
</tr>
<tr>
<td width="82" height="25" align="center"><span class="STYLE2">用户名:</span></td>
<td width="168"><input name="userid" type="text" id="userid" size="20"></td>
<td width="88"> </td>
</tr>
<tr>
<td height="25" align="center" class="STYLE2">密码:</td>
<td><input name="username" type="text" id="username" size="20"></td>
<td> </td>
</tr>
<tr>
<td height="40" align="center" class="STYLE2">地址:</td>
<td><input name="address" type="text" id="address" size="22"></td>
<td><input type="submit" name="Submit" value="提交"></td>
</tr>
</form>
</table>
</body> 展开
<?php session_start();
include("conn/conn.php");
if($Submit==true){
$query=mysql_query("SELECT FROM user WHERE username='$username'",$link);
if(mysql_num_rows($query)>0){echo "该用户已经存在";
}else{
$querys ="INSERT INTO user(userid,username,address) VALUES('$userid','$username','$address')";
$result=mysql_query($querys);
if($result==true){
echo"gualiyuanzhucechengg";
}else{echo "注册失败";}}}
?>
conn/conn.php的代码
<?php
$link=mysql_connect('localhost','root','123456') or die('can not connect');;
mysql_select_db('kqwr',$link);
mysql_query("set names gb2312")
?>
index的代码
<body>
<table width="360" border="1">
<form name="form1" method="post" action="index_ok.php">
<tr>
<td height="40" colspan="3" align="center"><span class="STYLE1">管理员注册</span></td>
</tr>
<tr>
<td width="82" height="25" align="center"><span class="STYLE2">用户名:</span></td>
<td width="168"><input name="userid" type="text" id="userid" size="20"></td>
<td width="88"> </td>
</tr>
<tr>
<td height="25" align="center" class="STYLE2">密码:</td>
<td><input name="username" type="text" id="username" size="20"></td>
<td> </td>
</tr>
<tr>
<td height="40" align="center" class="STYLE2">地址:</td>
<td><input name="address" type="text" id="address" size="22"></td>
<td><input type="submit" name="Submit" value="提交"></td>
</tr>
</form>
</table>
</body> 展开
1个回答
展开全部
<?php
$link=mysql_connect('localhost','root','123456') or die('can not connect');;
mysql_select_db('kqwr',$link);
mysql_query("set names gb2312")
?>
最后一句没有分号
$link=mysql_connect('localhost','root','123456') or die('can not connect');;
mysql_select_db('kqwr',$link);
mysql_query("set names gb2312")
?>
最后一句没有分号
更多追问追答
追问
改了·还是不行。。进到index_ok那个页面就没反应
追答
$Submit 改成 $_POST['Submit']
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询