Advertisement
Guest User

register

a guest
Oct 12th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.76 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. include("../connection.php");
  4. $Name = mysqli_real_escape_string($conn, $_POST["fname"]);
  5. $Lastname = mysqli_real_escape_string($conn, $_POST["lname"]);
  6. $Username = mysqli_real_escape_string($conn, $_POST['username']);
  7. $Password = mysqli_real_escape_string($conn, $_POST['password']);
  8. $RePass = mysqli_real_escape_string($conn, $_POST['retypepassword']);
  9. $Phone = mysqli_real_escape_string($conn, $_POST['phone']);
  10. $Email = mysqli_real_escape_string($conn, $_POST['email']);
  11. $Gender = mysqli_real_escape_string($conn, $_POST['gender']);
  12. $City = mysqli_real_escape_string($conn, $_POST['city']);
  13. $Country = mysqli_real_escape_string($conn, $_POST['country']);
  14. //encryption on password
  15. //$salt = bin2hex(mcrypt_create_iv(32, MCRYPT_DEV_URANDOM));
  16. //$saltedPW = $Password.$salt;
  17. $userlower = strtolower($Username);
  18. $hashedPW = hash('sha256', $Password);
  19. //end of encrytion
  20. if ($Password==$RePass) {
  21.     $query_verify_email = "SELECT * FROM tblcustomers WHERE Email = '$Email'";
  22.     $verified_email = $conn->query($query_verify_email);
  23.     if ($verified_email->num_rows == 0) {
  24.         $hash = md5(uniqid(rand(), true));
  25.         $sql = "INSERT INTO tblcustomers (FirstName,LastName,Username,Password,Contact,Email,Gender,City,Country,Type,Active,Verification,Code)
  26.         VALUE ('$Name','$Lastname','$userlower','$hashedPW','$Phone','$Email','$Gender','$City','$Country','User','Activate',0,'$hash')";
  27.         if($conn ->query($sql) === TRUE) {
  28.             /*echo '<script type="text/javascript">';
  29.             echo 'alert("A confirmation email has been sent to '. $Email.' Please click on the Activate Button to Activate your account");';
  30.             echo 'window.location.href = "verify.php?key='.$hash.'&emailaddress='. urlencode($Email) .'"';
  31.             echo '</script>';*/
  32.             if ($conn->affected_rows==1) {
  33.                 $subject = 'Activate Your Email';
  34.  
  35.                 $headers = "From: westviewpension.com \r\n";
  36.                 $headers .= "MIME-Version: 1.0\r\n";
  37.                 $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
  38.                 //$url= BASE_PATH . '/verify.php?emailaddress=' . urlencode($Email) . '&key='.$hash.'';
  39.                 $url= 'localhost/OnlineReservationv.02.3/verify.php?emailaddress=' . urlencode($Email) . '&key='.$hash.'';
  40.  
  41.                 $message =  '<h1>Thank you</h1>';
  42.                 $message .= '<p>Your username is: '. $Username .'</p>';
  43.                 $message .=  '<p>To activate your account please click on Activate buttton</p>';
  44.                 $message .=  '<p>If the link doesnt work just copy the link below.</p>';
  45.                 $message .=  '<p>'.$url.'</p>';
  46.                 $message .= '<table cellspacing="0" cellpadding="0"> <tr>';
  47.                 $message .= '<td align="center" width="300" height="40" bgcolor="#000091" style="-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;color: #ffffff; display: block;">';
  48.                 $message .= '<a href="'.$url.'" style="color: #ffffff; font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none;line-height:40px; width:100%; display:inline-block">Click to Activate</a>';
  49.                 $message .= '</td> </tr> </table>';
  50.                 if (mail($Email, $subject, $message, $headers)) {
  51.                     echo '<script type="text/javascript">';
  52.                     echo 'alert("A confirmation email has been sent to '. $Email.' Please click on the Activate Button to Activate your account");';
  53.                     //echo 'window.location.href = "verify.php?emailaddress='. urlencode($Email) .'&key='.$hash.'"';
  54.                     echo 'window.location.href = "../index.php";';
  55.                     echo '</script>';
  56.                 } else {
  57.                     die('Failure: Email was not sent!');
  58.                     echo 'window.location.href = "../index.php";';
  59.                 }
  60.             } else {
  61.                 echo '<script type="text/javascript">';
  62.                 echo 'alert("You could not be registered due to a system error. We apologize for any inconvenience.");';
  63.                 echo 'window.location.href = "../index.php";';
  64.                 echo '</script>';
  65.             }
  66.         } else {
  67.             echo '<script type="text/javascript">';
  68.             echo 'alert("Username is already use.");';
  69.             echo 'window.location.href = "../index.php";';
  70.             echo '</script>';
  71.         }
  72.     } else {
  73.         echo '<script type="text/javascript">';
  74.         echo 'alert("Email Address is already use.");';
  75.         echo 'window.location.href = "../index.php";';
  76.         echo '</script>';
  77.     }
  78. } else {
  79.     echo '<script type="text/javascript">';
  80.     echo 'alert("Password Do Not Match!");';
  81.     echo 'window.location.href = "../index.php";';
  82.     echo '</script>';
  83. }
  84. $conn->close();
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement