<?php$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];if($username == ""){
exit("用户名不能为空");
}
if($password != $password2){
exit("两次输入的密码不一致");
}
$host="localhost";
$user="root";
$pwd="";
$dbname="chuanke";
$connection = mysql_connect($host,$user,$pwd);
if($connection){

  $password = md5 ($password);
  mysql_select_db($dbname,$connection);
  $sql = "INSERT INTO `userinfo` (`UserName`,`Password`) VALUES('$username','$password')";
  $result = mysql_query($sql);
  
  if($result){
     echo $username."注册成功";
 
 }else{
 die("注册失败");
 }
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset;utf8;" />
<title>注册</title>
</head><body>
<form method="post" action="register.php">
<p>用户名:<input type="text" name="username" ></p>
<p>登陆密码:<input type="password" name="password" ></p>
<p>确认密码:<input type="password" name="password2" ></p>  <input type="submit" value="注册">
</form>
</body>
</html>