Hi, I'm using dreamweaver CS3 they provide behavior for checkout username, but what I do not like if user name exit that will redirect to other page inform them that user name is exit., I'm trying to do is to change code to show message inside of same page using javascripts instead of going to other page. But I couldn't figure out what to change code.
Please see part of this code in php, as you can see in code in bold, how is possible that i can change by not rediect to other page but stay same page and point the javascripts function called username(), to say user name is exit!
does any one can help me please. thanks.
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
[B]$MM_dupKeyRedirect="UserExit.php";[/B]
$loginUsername = $_POST['four'];
$LoginRS__query = sprintf("SELECT User_Name FROM signup WHERE User_Name=%s", GetSQLValueString($loginUsername, "text"));
mysql_select_db($database_RegData, $RegData);
$LoginRS=mysql_query($LoginRS__query, $RegData) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
}
}
$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 signup (First_Name, Last_Name, Email, User_Name, Password, Password2) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['one'], "text"),
GetSQLValueString($_POST['two'], "text"),
GetSQLValueString($_POST['three'], "text"),
GetSQLValueString($_POST['four'], "text"),
GetSQLValueString($_POST['five'], "text"),
GetSQLValueString($_POST['six'], "text"));
mysql_select_db($database_RegData, $RegData);
$Result1 = mysql_query($insertSQL, $RegData) or die(mysql_error());
$insertGoTo = "../MemberIndex.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>