Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <font color="white">
  2. <?php
  3. include("config/db.php");
  4. //This code runs if the form has been submitted
  5. if (isset($_POST['submit'])) {
  6.  
  7. //This makes sure they did not leave any fields blank
  8. if (!$_POST['username'] | !$_POST['pass'] | !$_POST['cpass']) {
  9. die('You did not complete all of the required fields');
  10. }
  11.  
  12. // checks if the username is in use
  13. if (!get_magic_quotes_gpc()) {
  14. $_POST['username'] = addslashes($_POST['username']);
  15. }
  16. $usercheck = $_POST['username'];
  17. $check = mysql_query("SELECT name FROM accounts WHERE name = '$usercheck'") or die(mysql_error());
  18. $check2 = mysql_num_rows($check);
  19.  
  20. //if the name exists it gives an error
  21. if ($check2 != 0) {
  22. die('Sorry, the username '.$_POST['username'].' is already in use.');
  23. }
  24. if ($_POST['pass'] != $_POST['cpass']) {
  25. die('Your passwords did not match. ');
  26. }
  27.  
  28. // here we encrypt the password and add slashes if needed
  29. $_POST['pass'] = sha1($_POST['pass']);
  30. if (!get_magic_quotes_gpc()) {
  31. $_POST['pass'] = addslashes($_POST['pass']);
  32. $_POST['username'] = addslashes($_POST['username']);
  33. }
  34.  
  35. // now we insert it into the database
  36. $insert = "INSERT INTO accounts (name, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
  37. $add_member = mysql_query($insert);
  38. echo" <center>Your account has successfully been created! You may now login!</center>";
  39. }
  40. ?>
  41. </font>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement