Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php require_once('Connections/sql_connection.php'); ?>
- <?php
- if (!function_exists("GetSQLValueString")) {
- function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
- {
- if (PHP_VERSION < 6) {
- $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
- }
- $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($database_sql_connection,$theValue) : mysqli_escape_string($database_sql_connection,$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="Register.php";
- $loginUsername = $_POST['email_address'];
- $LoginRS__query = sprintf("SELECT email_address FROM employee WHERE email_address=%s", GetSQLValueString($loginUsername, "text"));
- mysqli_select_db($sql_connection,$database_sql_connection);
- $LoginRS=mysqli_query($LoginRS__query, $sql_connection) or die(mysql_error());
- $loginFoundUser = mysqli_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"] == "RegisterForm")) {
- $insertSQL = sprintf("INSERT INTO employee (first_name, last_name, email_address, password) VALUES (%s, %s, %s, %s)",
- GetSQLValueString($_POST['first_name'], "text"),
- GetSQLValueString($_POST['last_name'], "text"),
- GetSQLValueString($_POST['email_address'], "text"),
- GetSQLValueString($_POST['password'], "text"));
- mysqli_select_db($database_sql_connection, $sql_connection);
- $Result1 = mysqli_query($insertSQL, $sql_connection) or die(mysql_error());
- $insertGoTo = "Login.php";
- if (isset($_SERVER['QUERY_STRING'])) {
- $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
- $insertGoTo .= $_SERVER['QUERY_STRING'];
- }
- header(sprintf("Location: %s", $insertGoTo));
- }
- mysqli_select_db($sql_connection,$database_sql_connection);
- $query_Register = "SELECT employee.first_name, employee.last_name, employee.email_address, employee.password FROM employee";
- $Register = mysqli_query($sql_connection,$query_Register) or die(mysqli_error());
- $row_Register = mysqli_fetch_assoc($Register);
- $totalRows_Register = mysqli_num_rows($Register);
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <link href="CSS/layout.css" rel="stylesheet" type="text/css" />
- <link href="CSS/menu.css" rel="stylesheet" type="text/css" />
- <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
- <link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" />
- <link href="SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css" />
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>o-dtr</title>
- <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
- <script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script>
- <script src="SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script>
- </head>
- <body>
- <div id="Holder">
- <div id="Header"></div>
- <div id="NavBar">
- <nav>
- <ul>
- <li><a href="Login.php">Login</a></li>
- <li>|</li>
- <li><a href="Register.php"> Register</a></li>
- <li>|</li>
- <li><a href="ForgotPassword.php">Forgot Password</a></li>
- </ul>
- </nav>
- </div>
- <div id="Content">
- <form id="RegisterForm" name="RegisterForm" method="POST" action="<?php echo $editFormAction; ?>">
- <table width="600" border="0" align="center">
- <tr>
- <td><table border="0">
- <tr>
- <td><span id="sprytextfield1">
- <label for="first_name"></label>
- First Name:<br />
- <input name="first_name" type="text" class="StyleTextField" id="first_name" />
- <span class="textfieldRequiredMsg">A value is required.</span></span></td>
- <td><span id="sprytextfield2">
- <label for="last_name"></label>
- Last Name:<br />
- <input name="last_name" type="text" class="StyleTextField" id="last_name" />
- <span class="textfieldRequiredMsg">A value is required.</span></span></td>
- </tr>
- </table></td>
- </tr>
- <tr>
- <td> </td>
- </tr>
- <tr>
- <td><span id="sprytextfield3">
- <label for="email_address"></label>
- Email:<br />
- <input name="email_address" type="text" class="StyleTextField" id="email_address" />
- <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
- </tr>
- <tr>
- <td> </td>
- </tr>
- <tr>
- <td><table border="0">
- <tr>
- <td><span id="sprypassword1">
- <label for="password"></label>
- Password:<br />
- <input name="password" type="password" class="StyleTextField" id="password" />
- <span class="passwordRequiredMsg">A value is required.</span></span></td>
- <td><span id="spryconfirm1">
- <label for="passwordconfirm"></label>
- Confirm Password:<br />
- <input name="passwordconfirm" type="password" class="StyleTextField" id="passwordconfirm" />
- <span class="confirmRequiredMsg">A value is required.</span><span class="confirmInvalidMsg">The values don't match.</span></span></td>
- </tr>
- </table></td>
- </tr>
- <tr>
- <td> </td>
- </tr>
- <tr>
- <td><input type="submit" name="RegisterButton" id="RegisterButton" value="Register" /></td>
- </tr>
- </table>
- <input type="hidden" name="MM_insert" value="RegisterForm" />
- </form>
- </div>
- <div id="Footer"></div>
- </div>
- <script type="text/javascript">
- var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
- var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
- var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "email");
- var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1");
- var spryconfirm1 = new Spry.Widget.ValidationConfirm("spryconfirm1", "password");
- </script>
- </body>
- </html>
- <?php
- mysql_free_result($Register);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement