创建reg.php文件
我们在php页面主要做以下功能
代码如下<?php
session_start();
header("Content-type:text/html;charset=utf-8");
$link = mysqli_connect('localhost','root','root','login');
mysqli_set_charset($link,'utf8'); //设定字符集
$name=$_POST['name'];
$pwd=$_POST['pwd'];
$pwdconfirm=$_POST['pwdconfirm'];
$yzm=$_POST['yzm'];
if($name==''){
echo"";
exit;
}
if($pwd==''){
echo"";
exit;
}
if($pwd != $pwdconfirm){
echo"";
exit;
}
if($yzm!=$_SESSION['VCODE']){
echo"";
exit;
}
$insert_sql="insert into user(username,password)values(? , ? )";
$stmt=mysqli_prepare($link,$insert_sql);
mysqli_stmt_bind_param($stmt,'ss',$name,$pwd);
$result_insert=mysqli_stmt_execute($stmt);
if($result_insert){
echo "";
exit;
}else {
echo "";
exit;
}
?>