Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.33 KB | None | 0 0
  1. <html>
  2.  
  3. <BODY  Link="green" ALink="darkgreen" VLink="darkgreen">
  4. <font face="trebuchet MS">
  5.  
  6. Registreren:
  7.  
  8. <?php
  9.  
  10. mysql_connect("mysql6.000webhost.com", "a3991364_001", "siteLP1109") or die(mysql_error());
  11. mysql_select_db("a3991364_001") or die(mysql_error());
  12.  
  13. //This code runs if the form has been submitted
  14.  
  15. if (isset($_POST['submit'])) {
  16.  
  17.  
  18.  
  19. //This makes sure they did not leave any fields blank
  20.  
  21. if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
  22.  
  23.         die('You did not complete all of the required fields');
  24.  
  25.     }
  26.  
  27.  
  28.  
  29. // checks if the username is in use
  30.  
  31.     if (!get_magic_quotes_gpc()) {
  32.  
  33.         $_POST['username'] = addslashes($_POST['username']);
  34.  
  35.     }
  36.  
  37. $usercheck = $_POST['username'];
  38.  
  39. $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'")
  40.  
  41. or die(mysql_error());
  42.  
  43. $check2 = mysql_num_rows($check);
  44.  
  45.  
  46.  
  47. //if the name exists it gives an error
  48.  
  49. if ($check2 != 0) {
  50.  
  51.         die('Sorry, the username '.$_POST['username'].' is already in use.');
  52.  
  53.                 }
  54.  
  55.  
  56. //
  57. this makes sure both passwords entered match
  58.  
  59.     if ($_POST['pass'] != $_POST['pass2']) {
  60.  
  61.         die('Your passwords did not match. ');
  62.  
  63.     }
  64.  
  65.  
  66.  
  67.     // here we encrypt the password and add slashes if needed
  68.  
  69.     $_POST['pass'] = md5($_POST['pass']);
  70.  
  71.     if (!get_magic_quotes_gpc()) {
  72.  
  73.         $_POST['pass'] = addslashes($_POST['pass']);
  74.  
  75.         $_POST['username'] = addslashes($_POST['username']);
  76.  
  77.             }
  78.  
  79.  
  80.  
  81. // now we insert it into the database
  82.  
  83.     $insert = "INSERT INTO users (username, password)
  84.             VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
  85.  
  86.     $add_member = mysql_query($insert);
  87.  
  88.     ?>
  89.  
  90.  
  91.  
  92.  
  93.  <h1>Registered</h1>
  94.  
  95.  <p>Thank you, you have registered - you may now login</a>.</p>
  96.  
  97.  <?php
  98. }
  99.  
  100. else
  101.  { 
  102. ?>
  103.  
  104.  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  105.  
  106.  <table border="0">
  107.  
  108.  <tr><td>Username:</td><td>
  109.  
  110.  <input type="text" name="username" maxlength="60">
  111.  
  112.  </td></tr>
  113.  
  114.  <tr><td>Password:</td><td>
  115.  
  116.  <input type="password" name="pass" maxlength="10">
  117.  
  118.  </td></tr>
  119.  
  120.  <tr><td>Confirm Password:</td><td>
  121.  
  122.  <input type="password" name="pass2" maxlength="10">
  123.  
  124.  </td></tr>
  125.  
  126.  <tr><th colspan=2><input type="submit" name="submit"
  127. value="Register"></th></tr> </table>
  128.  
  129.  </form>
  130.  
  131.  
  132.  <?php
  133.  
  134. }
  135. ?>
  136.  
  137. </font>
  138. </body>
  139. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement