猿问

为什么我写的用户注册实现不了,求解答哪里错了??

<?php session_start();

include('conn.php');

header("content-type:text/html;charset=utf-8");

if (isset($_POST['apply'])){

$user=$_POST['user'];

$password=$_POST['word'];

if($_POST['check']==$_SESSION['checkpic']){

echo "<SCRIPT language=javascript>

function CheckPost()

if (myform.user.value.length<2){

alert('用户名不能小于两个字符');

myform.user.focus();

return false;}

if (myform.word.value.length<6){

alert('密码不能少于6位');

myform.content.focus();

return false;}

</SCRIPT>";


$sql = "select username from user where username = '$password'"; //SQL语句  

$result = mysql_query($sql);    //执行SQL语句  

$num = mysql_num_rows($result); //统计执行结果影响的行数

if($num){

echo "<script>alert('用户名已存在')</script>"; 

}

else{

$sql1="INSERT INTO `user`(`id`, `user`, `password`) VALUES ('','$user','$password')";//插入用户信息

$result=mysql_query($sql1);

IF($result){

echo "<script>alert('注册成功!')</script>";

}

}

}

else {

echo "<script>alert('验证码错误')</script>";

}

}








?>


qq_學會忘記懂得放棄_0
浏览 1093回答 1
1回答
随时随地看视频慕课网APP
我要回答