Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'register.php';
- function check_email_address($email) {
- return filter_var($email, FILTER_VALIDATE_EMAIL) ? 1 : 0;
- }
- function error($error){
- $fullerror = "<center><div id=error><h2>Error:</h2><p>
- ".$error."</div></center>";
- die($fullerror);
- }
- if (isset($_POST['submit'])) {
- $username = $_POST["username"];
- $password = $_POST["password"];
- $email = $_POST["email"];
- $username = mysqli_real_escape_string($db, $username);
- $email = mysqli_real_escape_string($db, $email);
- $password = mysqli_real_escape_string($db, $password);
- $password2 = mysqli_real_escape_string($db, $password2);
- $username = addslashes($username);
- $email = addslashes($email);
- $password = addslashes($password);
- $password2 = addslashes($password2);
- $password = md5($password);
- if ($_POST['password']!= $_POST['password2'])
- {
- die("Oops! Password did not match! Try again. ");
- }
- if(strlen($_POST['password']) <= 3){
- error('Sorry, that password was too short.');
- }
- if(strlen($_POST['username']) <= 3){
- error('Sorry, that username was too short.');
- }
- $sql = "SELECT email FROM users WHERE email='$email'";
- $result = mysqli_query($db,$sql);
- $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
- $sql = "SELECT username FROM users WHERE username='$username'";
- $result = mysqli_query($db,$sql);
- $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
- if(mysqli_num_rows($result) == 1) {
- die("Sorry...This email already exist..");
- }
- if(mysqli_num_rows($result) == 2) {
- die("Sorry...This username already exist..");
- }
- $query = mysqli_query($db, "INSERT INTO users (`id`,`name`, `nickname`, `email`, `password`)VALUES ('$username', '$email', '$password')");
- if($query) {
- echo "Thank You! you are now registered.";
- }
- } else {
- ?>
- <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
- <fieldset>
- <legend>Registration Form</legend>
- <table width="400" border="0" cellpadding="10" cellspacing="10">
- <tr>
- <td style="font-weight: bold"><div align="right"><label for="name">username</label></div></td>
- <td><input name="username" type="text" class="input" size="25" required /></td>
- </tr>
- <tr>
- <td style="font-weight: bold"><div align="right"><label for="email">Email</label></div></td>
- <td><input name="email" type="email" class="input" size="25" required /></td>
- </tr>
- <tr>
- <td height="23" style="font-weight: bold"><div align="right"><label for="password">Password</label></div></td>
- <td><input name="password" type="password" class="input" size="25" required /></td>
- </tr>
- <td height="23" style="font-weight: bold"><div align="right"><label for="password">Re-enter your password</label></div></td>
- <td><input name="password2" type="password" class="input" size="25" required /></td>
- </tr>
- <tr>
- <td height="23"></td>
- <td><div align="right">
- <input type="submit" name="submit" value="Register!" />
- </div></td>
- </tr>
- </table>
- </fieldset>
- </form>
- <?php
- }
- ?>
Add Comment
Please, Sign In to add comment