<?php require_once('modulatemedia.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="register2.php";
$loginUsername = $_POST['username'];
$LoginRS__query = sprintf("SELECT username FROM members WHERE username=%s", GetSQLValueString($loginUsername, "text"));
mysql_select_db($database_modulatemedia, $modulatemedia);
$LoginRS=mysql_query($LoginRS__query, $modulatemedia) 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 members (firstname, lastname, username, password, email, recomendedbyid) VALUES (%s, %s, %s, md5(%s), %s, %s)",
GetSQLValueString($_POST['firstname'], "text"),
GetSQLValueString($_POST['lastname'], "text"),
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['recomendedbyid'], "int"));
mysql_select_db($database_modulatemedia, $modulatemedia);
$Result1 = mysql_query($insertSQL, $modulatemedia) or die(mysql_error());
$insertGoTo = "stores.html";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<label></label>
<table width="241" border="0" align="center">
<tr>
<td colspan="2"><h2 align="center" class="style4">Registration</h2> </td>
</tr>
<tr>
<td width="79"><span class="style3"><strong>
</strong>
</span> <span class="style2">
</span> <div align="right" class="style3"><strong>*Username:</strong></div> </td>
<td width="152"><input name="username" type="text" id="username" tabindex="1" maxlength="20" /></td>
</tr>
<tr>
<td><span class="style3"><strong>
</strong>
</span> <span class="style2">
</span> <div align="right" class="style3"><strong>*Password:</strong></div> </td>
<td><input name="password" type="password" id="password" tabindex="2" maxlength="20" /></td>
</tr>
<tr>
<td><span class="style3"><strong>
</strong>
</span> <span class="style2">
</span> <div align="right" class="style3"><strong>*Email:</strong></div> </td>
<td><input name="email" type="text" id="email" tabindex="3" maxlength="50" /></td>
</tr>
<tr>
<td class="style3"><div align="right"><strong>*Firstname:</strong></div></td>
<td><input name="firstname" type="text" id="firstname" tabindex="3" maxlength="50" /></td>
</tr>
<tr>
<td class="style3"><div align="right"><strong>*Lastname:</strong></div></td>
<td><input name="lastname" type="text" id="lastname" tabindex="3" maxlength="50" /></p></td>
</tr>
<tr>
<td><div align="right">*Referal ID</div></td>
<td><?php $id = $_GET['id']; ?>
<input type="int" name="id" id="textfield"?></td>
</tr>
<tr>
<td> </td>
<td><input name="submit" type="submit" id="submit" tabindex="4" onclick="MM_validateForm('username','','R');MM_validateForm('password','','R');MM_validateForm('email','','RisEmail');return document.MM_returnValue" value="Register" /></td>
</tr>
<tr>
<td> </td>
<td><span class="style7"><a href="file:///C|/Users/Up Stairs/Desktop/login script/login.php">login</a></span></td>
</tr>
<tr>
<td> </td>
<td><span class="style7">*required fields</span></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>