代码奉上
报错信息:数据插入失败,请重试
<?php
session_start();
header("Content-type:text/html;charset=utf-8");
//登陆数据库
$link = mysqli_connect('localhost','ClassCard','nMRZrC42wDjWHeAL','ClassCard');
if (!$link) {
die("连接失败:".mysqli_connect_error());
}
$Name = $_POST['Name'];
$ID = $_POST['ID'];
$Phone = $_POST['Phone'];
//填写错误判定
if($Name == "" || $ID == "" || $Phone == "")
{
echo ('以上三项不能为空!重新填写');
}
//重复注册判定
$sql="select*from UserST WHERE Name = '$Name' AND ID = '$ID'";
$result=mysqli_query($link,$sql);
$row=mysqli_fetch_assoc($result);
$PassName = $row["Name"];
$PassId = $row["ID"];
if($Name == "$PassName" && $ID == "$PassId")
{
echo "该用户已注册,请勿重复注册";
}
//执行写入操作
else
{
date_default_timezone_set('prc');
$RegisterTime = date('Y-m-d',time());
$sql = "INSERT INTO UserST VALUES ('$ID', '$Name', '', '0', '新开', '$RegisterTime', '$Phone')";
if(!(mysqli_query($link,$sql)))
{
echo ('数据插入失败,请重试');
}
else
{
echo ('录入成功!');
}
mysqli_close($link);
}
?>