Guest User

Untitled

a guest
Jul 19th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <?php
  2. // Connect to the database
  3. require_once 'config.php';
  4.  
  5. if (isset($_POST['submit'])) {
  6. $login = $_POST['username'];
  7. $pass = $_POST['pass'];
  8. $passcheck = $_POST['pass2'];
  9.  
  10. // Are any fields blank?
  11. if (!$login | !$pass | !$passcheck ) {
  12. die('One or more fields were left empty, please make sure you fill every field.');
  13. }
  14. if (!get_magic_quotes_gpc()) {
  15. $login = addslashes($login);
  16. }
  17.  
  18. // Is this username in use?
  19. $check = mysql_query("SELECT login FROM clerk WHERE login = '$login'") or die(mysql_error());
  20. $check2 = mysql_num_rows($check);
  21.  
  22. if ($check2 != 0) {
  23. die('Sorry, the username '.$login.' is already in use.');
  24. }
  25.  
  26. // Do the passwords match?
  27. if ($pass != $passcheck) {
  28. die('Your passwords did not match.');
  29. }
  30.  
  31. // Insert into DB
  32. $insert = "INSERT INTO clerk (login, PWORD) VALUES ('".$login."', '".$pass."')";
  33. $add_member = mysql_query($insert);
  34. ?>
  35.  
  36.  
  37. <h1>Registered</h1>
  38. <p>Thank you, you have registered - you may now <a href= login.php>login</a>.</p>
  39.  
  40. <?php
  41. }
  42. else
  43. {
  44. ?>
  45.  
  46.  
  47. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  48. <table border="0">
  49. <tr><td>Login:</td><td>
  50. <input type="text" name="username" maxlength="20">
  51. </td></tr>
  52. <tr><td>Password:</td><td>
  53. <input type="password" name="pass2" maxlength="20">
  54. </td></tr>
  55. <tr><td>Confirm Password:</td><td>
  56. <input type="password" name="passcheck" maxlength="20">
  57. </td></tr>
  58. <tr><td>First name:</td><td>
  59. <input type="text" name="Fname" maxlength="30">
  60. </td></tr>
  61. <tr><td>Last name:</td><td>
  62. <input type="text" name="Lname" maxlength="30">
  63. </td></tr>
  64. <tr><td>Address:</td><td>
  65. <textarea name="address" cols="40" rows="5">
  66. </textarea>
  67. </td></tr>
  68. <tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table>
  69. </form>
  70.  
  71. <?php
  72. }
  73. mysql_close();
  74. ?>
Add Comment
Please, Sign In to add comment