Advertisement
Guest User

Untitled

a guest
Oct 25th, 2017
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. <?php
  2.  
  3. include ('dbconnect.php');
  4. session_start();
  5. date_default_timezone_set('UTC');
  6. $error='';
  7. if (isset($_POST['register'])) {
  8. if (empty($_POST['user']) || empty($_POST['email']) || empty($_POST['pass']) || empty($_POST['conpass'])) {
  9. $error = "Please fill in all information.";
  10. } else {
  11. $user_name=$_POST['user'];
  12. $email=$_POST['email'];
  13. $pass=$_POST['pass'];
  14. $tsql = "SELECT * FROM Accounts WHERE UserID='$user_name' AND email='$email'";
  15. $tQuery = sqlsrv_query($tsql);
  16. $tResult = sqlsrv_fetch_array($tQuery);
  17. if($_POST['pass'] != $_POST['conpass']){
  18. $error = 'Password not match';
  19. }
  20. if($tResult) {
  21. $error = "Username or Email has been used";
  22. } else {
  23. $hash = md5( rand(0,1000) );
  24. $str1 = "INSERT INTO Accounts WHERE (email, UserID, MD5Password, dateregistered, lastlogindate, lastloginIP, ReferralID, hash) VALUES ('" . $email . "','" . $user_name . "','" . $pass . "','" . date("Y-m-d H:i:s", time()) . "','" . date("Y-m-d H:i:s", time()) . "','127.0.0.1','0','" . $hash . "')";
  25. $lastindex = sqlsrv_execute("SELECT IDENT_CURRENT('Accounts') + 1 as lastindex");
  26. $LastID = sqlsrv_fetch_array($lastindex);
  27. $str2 = "INSERT INTO UsersData WHERE (CustomerID, AccountType, dateregistered) VALUES ( '" . $LastID['lastindex'] . "', '2', '" . date("Y-m-d H:i:s", time()) . "')";
  28. if (sqlsrv_execute($conn, $str1) && sqlsrv_execute($conn, $str2)) {
  29. $_SESSION['register_user'] = $user_name;
  30. $error = 'Your account has been made, <br/> please verify it by clicking the activation link that has been send to your email.';
  31. $to = $email;
  32. $subject = 'Signup | Verification';
  33. $message = '
  34.  
  35. Thanks for signing up!
  36. Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.
  37.  
  38. Username: '.$name.'
  39. ------------------------
  40.  
  41. Please click this link to activate your account:
  42. http://127.0.0.1/Undead/verify.php?email='.$email.'&hash='.$hash.'
  43.  
  44. ';
  45.  
  46. $headers = 'From:noreply@playundead.com' . "\r\n";
  47. mail($to, $subject, $message, $headers);
  48. } else {
  49. $error = 'System error';
  50. }
  51. }
  52.  
  53. }
  54. }
  55.  
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement