Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. <?php
  2.  
  3. // Connects to your Database
  4. require_once('include/config.php');
  5. require_once('include/bodyin.html');
  6. require_once('include/core.php');
  7. dbconn();
  8.  
  9. //This code runs if the form has been submitted
  10. if (isset($_POST['submit'])) {
  11.  
  12. //This makes sure they did not leave any fields blank
  13. if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
  14. die('You did not complete all of the required fields');
  15. }
  16.  
  17. print_r($_POST);
  18. die;
  19. // checks if the username is in use
  20.  
  21. $usercheck = sqlesc($_POST['username']);
  22. $check = mysql_query("SELECT username FROM signup WHERE username = ".$usercheck)
  23. or die(mysql_error());
  24. $check2 = mysql_num_rows($check);
  25.  
  26. //if the name exists it gives an error
  27. if ($check2 != 0) {
  28. die('Sorry, the username '.safe($_POST['username']).' is already in use.');
  29. }
  30.  
  31. // this makes sure both passwords entered match
  32. if ($_POST['pass'] != $_POST['pass2']) {
  33. die('Your passwords did not match. ');
  34. }
  35.  
  36. $sec = mksecret();
  37. $passhash = md5($sec.$_POST['pass'].$sec);
  38.  
  39. // now we insert it into the database
  40. $insert = "INSERT INTO signup (username, password, secret)
  41. VALUES (".sqlesc($_POST['username']).", ".sqlesc($passhash).", ".sqlesc($sec).")";
  42. mysql_query($insert);
  43. ?>
  44.  
  45.  
  46. <h1>Registered</h1>
  47. <p>Thank you, new user added</a>.</p>
  48.  
  49.  
  50. <?php
  51. }
  52. else
  53. {
  54. ?>
  55.  
  56.  
  57. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  58. <table border="0">
  59. <tr><td>Username:</td><td>
  60. <input type="text" name="username" maxlength="60">
  61. </td></tr>
  62. <tr><td>Password:</td><td>
  63. <input type="password" name="pass" maxlength="10">
  64. </td></tr>
  65. <tr><td>Confirm Password:</td><td>
  66. <input type="password" name="pass2" maxlength="10">
  67. </td></tr>
  68. <tr><th colspan=2><input type="submit" name="submit" value="Add user"></th></tr> </table>
  69. </form>
  70.  
  71. <?php
  72. }
  73. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement