我有以下正确发布的代码,但我想重定向到站点 index.php 页面并且无法弄清楚。我到处搜索并尝试了几乎所有方法,但都没有成功。任何帮助表示赞赏。
$editFormAction = $_SERVER['PHP_SELF'];
$query_dupUserCheck = "SELECT tblUser.userKey FROM tblUser WHERE tblUser.username = '".$_POST['username']."'";
$sqlsearch = mysql_query($query_dupUserCheck);
$resultcount = mysql_numrows($sqlsearch);
$query_dupUserCheck2 = "SELECT tblUser.userKey FROM tblUser WHERE tblUser.email = '".$_POST['user_email']."'";
$sqlsearch2 = mysql_query($query_dupUserCheck2);
$resultcount2 = mysql_numrows($sqlsearch2);
if ($resultcount > 0 & $resultcount2 > 0) {
print("That Username and Email Already Exists");
} else {
if ($resultcount > 0) {
print("That Username Already Exists");
} else {
if ($resultcount2 > 0) {
print("That Email Already Exists");
} else {
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "createAccount")) {
$insertSQL = sprintf("INSERT INTO tblUser (username, password, userTypeKey, email) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['user_password2'], "text"),
GetSQLValueString($_POST['userType'], "int"),
GetSQLValueString($_POST['user_email'], "text"));
mysql_select_db($database_ignite, $ignite);
$Result1 = mysql_query($insertSQL, $ignite) or die(mysql_error());
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location : %s", $insertGoTo));
}
}}}
表单调用动作
<?php echo $editFormAction;?>