Advertisement
Guest User

Untitled

a guest
May 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.88 KB | None | 0 0
  1. <?php
  2. $username = $_POST['username'];
  3. $email = $_POST['email'];
  4. $password = $_POST['password'];
  5. $cpassword = $_POST['cpassword'];
  6. $ip = @REMOTE_ADDR;
  7.  
  8. // Connect To The MySQL DataBase for assigment
  9. $connect = mysql_connect('db host removed', 'db username removed', 'db password removed');
  10.  
  11. // Could not connect, echo an error messsage
  12.  
  13. if (!$connect)
  14.     {
  15.         die('Error: Could not connect to MySQL database. Please email support@Johtaja.x10.mx and tell them about this.');
  16.     }
  17.  
  18. // Select the DataBase
  19.  
  20. mysql_select_db("db name removed", $connect);
  21.  
  22. // Set query variable
  23.  
  24. //$selectusername = mysql_query("SELECT * FROM users
  25. //WHERE username='$username'");
  26.  
  27. // If statement making sure that the username isn't already taken
  28. //if (!$selectusername) {
  29. // Check to see if the conditions are perfect, a.k.a. there is a Username, there is a Email, there is a Password, there is a Confirmation Passowrd, and the Password and confirmation Passwords match
  30. if (!empty($username) && !empty($email) && !empty($password) && !empty($cpassword) && $password == $cpassword) {
  31.  
  32. // Set query for making the assignment table
  33.  
  34. $sqlquery = "CREATE TABLE " . $user . " {
  35.     name varchar(30),
  36.     due varchar(50),
  37.     course varchar(50),
  38.     description varchar(1000)
  39. }";
  40.  
  41. // Could not query, echo an error message
  42.  
  43. if (!mysql_query($sqlquery,$connect))
  44.     {
  45.         //die('Error: Could not query MySQL database. Please email support@Johtaja.x10.mx and tell them about this.');
  46.     }
  47.  
  48. // Query INSERT INTO command
  49.  
  50. $sqlquery1 = "INSERT INTO users (username, email, password)
  51. VALUES
  52. ('$username', '$email', '$password')";
  53.  
  54. // Could not query, echo an error message
  55.  
  56. if (!mysql_query($sqlquery1,$connect))
  57.     {
  58.         die('Error: Could not query MySQL database. Please email support@Johtaja.x10.mx and tell them about this.');
  59.     }
  60.  
  61.  
  62. // Set variables for the email
  63. $to = $email;
  64. $subject = "Johtaja Account Information";
  65. $message = "Thank you for signing up for Johtaja! Here is your account information:\n" .
  66.     "Username: $username\n" .
  67.     "Email: $email\n" .
  68.     "Password: $password\n" .
  69.     "You may sign in at Johtaja.x10.mx  Please keep this information in case you need it later.";
  70. $headers = "From: support@Johtaja.x10.mx";
  71.  
  72. // Send the email
  73. mail($to, $subject, $message, $headers);
  74.  
  75. // Tell them that everything went well
  76. echo "Account Created!<br />";
  77. echo "Username: " . $username . "<br />";
  78. echo "Email: " . $email . "<br />";
  79. echo "Account Information Has Been Sent To " . $email . ".<br />";
  80. }
  81.  
  82. // The user didn't enter username
  83.  
  84. if (empty($username)) {
  85.  
  86. // Tell them that they must enter a username
  87.  
  88. echo "You must enter a password. Please press the back button on your web browser and enter a username.<br />";
  89. }
  90.  
  91. // The user didn't enter an email
  92.  
  93. if (empty($email)) {
  94.    
  95. // Tell them that they must enter an email
  96.  
  97. echo "You must enter an email. Please press the back button on your web browser and enter an email.<br />";
  98. }
  99.  
  100. // The user didn't enter a password
  101.  
  102. if (empty($password)) {
  103.  
  104. // Tell them that they must enter a password
  105.  
  106. echo "You must enter a password. Please press the back button on your web browser and enter a password.<br />";
  107. }
  108.  
  109. // The user didn't confirm their password
  110.  
  111. if (empty($cpassword)) {
  112.  
  113. // Tell them that they must confirm thier password
  114.  
  115. echo "You must confirm you password. Please press the back button on your web browser and confirm you password.<br />";
  116. }
  117.  
  118. // The password and confirmed passwords don't match
  119.  
  120. if ($password !== $cpassword) {
  121.  
  122. // Tell them that the passwords must match
  123.  
  124. echo "The password and confirmation password must match. Please press the back button on you web browser and re-enter your password and confirmation password";
  125. }
  126. //}
  127.  
  128. // The username is already taken
  129.  
  130. //else {
  131. //echo "The username " . $username . " is already taken. Please press the back button on your web browser and choose another username";
  132. //}
  133. mysql_close($connect);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement