Rumah >pembangunan bahagian belakang >tutorial php > php注册页面验证码,不知道哪儿有异常,每次提交就算验证码打错了,居然也能成功提交
php注册页面验证码,不知道哪儿有错误,每次提交就算验证码打错了,居然也能成功提交。
以下是注册页面的全部代码,每次提交验证码不管是输入正确还是错误,内容都会被成功提交。求解决大家看看代码哪儿有错误。
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO user_zc (username, pass, phonenumber, realname, sex) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['pass'], "text"),
GetSQLValueString($_POST['phonenumber'], "int"),
GetSQLValueString($_POST['realname'], "text"),
GetSQLValueString($_POST['select'], "text"));
if ($_POST['yzm'] !== $_SESSION["vocode"]) {
header("location: ". "user_zcsb.php" );
}
mysql_select_db($database_conn, $conn);
$Result1 = mysql_query($insertSQL, $conn) or die(mysql_error());
$insertGoTo = "user_zccg.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>