i'm not sure where i should add those codes.
i dont need validations for null values. Just need to compare password and confirm password as well as email and confirm e-mail.
Been trying various ways to insert codes but i get undefined errors.
my codes. Someone give me guidance where i should add please. 😕
<?php require_once('../Connections/a.php'); ?>
<?php
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="register.php?error=cuid";
$loginUsername = $_POST['uid'];
$LoginRS__query = "SELECT uid FROM usertbl WHERE uid='" . $loginUsername . "'";
mysql_select_db($database_a, $a);
$LoginRS=mysql_query($LoginRS__query, $a) 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;
}
}
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}
/*if()
{
if((strcmp($_POST['pwd'],$_POST['cpwd']))==0)
{
}
$MM_dupKeyRedirect="register.php";
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 usertbl (uid, pwd, FirstName, LastName, gender, address, `level`, mail, contact) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['uid'], "text"),
GetSQLValueString($_POST['pwd'], "text"),
GetSQLValueString($_POST['fname'], "text"),
GetSQLValueString($_POST['Lname'], "text"),
GetSQLValueString($_POST['gender'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['level'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['contact'], "int"));
mysql_select_db($database_a, $a);
$Result1 = mysql_query($insertSQL, $a) or die(mysql_error());
$insertGoTo = "register.php?insert=true";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$stat = 'Guest';
?>