时间:2021-07-01 10:21:17 帮助过:20人阅读
header("Content-type: text/html; charset=utf-8");
if(!empty($_POST['username'])){
$name=$_POST['username'];
}
if(!empty($_POST['pwd'])){
$pwd=$_POST['pwd'];
}
function sqlDql($name,$pwd){
$conn=mysql_connect("localhost","root","root");
if(!$conn){
die("连接失败".mysql_error());
}
mysql_select_db("test",$conn) or die(mysql_error());
//设置字符集
mysql_query("set names utf8");
$sql="select * from zhuche;";
$res=mysql_query($sql,$conn) or die(mysql_error());
while($row=mysql_fetch_row($res)){
if($name==$row[1]){
echo "用户名已经存在
";
echo "返回注册页面";
// die(mysql_free_result($res)."连接".mysql_close($conn));
mysql_free_result($res);
mysql_close($conn);
exit();
}
}
$sql2="insert into zhuche (Username,password) values ('".$name."','".$pwd."');";
$res2=mysql_query($sql2,$conn) or die(mysql_error());
echo "
序号 | 用户 | 密码 |
--".$val." | ";