Advertisement
Guest User

Untitled

a guest
May 18th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. <html>
  2. <head>
  3. <basefont face="Arial">
  4. </head>
  5. <body>
  6.  
  7. <?php
  8.  
  9.  
  10. if (!isset($_POST['submit'])) {
  11. // form not submitted
  12.  
  13. ?>
  14.  
  15. <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
  16. <center><b>Register new user (Login v0.3 by Silence)</b><br /></center>
  17. <hr>
  18. <b>Username:</b> <input type="text" name="username">
  19. <b>Password:</b> <input type="text" name="passwdclear">
  20. <input type="submit" name="submit" value="Register">
  21. </form>
  22.  
  23. <?php
  24. }
  25.  
  26.  
  27. else {
  28. // form submitted
  29. // set server access variables & salt
  30. $host = "localhost"; // This is your hostname.
  31. $user = "root"; // This is your MySQL username.
  32. $pass = "akecbdy6"; // This is your MySQL password.
  33. $db = "passwd"; // This is the name of the database (line 47).
  34. $salt = "mysalt"; // This is set for crypting (line 50).
  35. $table = "details"; // This is the name of the table (line 53)
  36.  
  37. // get form input
  38. // check to make sure it's all there
  39. // escape input values for greater safety
  40. $username = empty($_POST['username']) ? die ("ERROR: Enter a username") : mysql_escape_string($_POST['username']);
  41. $passwdclear = empty($_POST['passwdclear']) ? die ("ERROR: Enter a password") : mysql_escape_string($_POST['passwdclear']);
  42.  
  43. // open connection
  44. $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
  45.  
  46. // select database
  47. mysql_select_db($db) or die ("Unable to select database!");
  48.  
  49. // crypt before entry into DB
  50. $password = crypt($passwdclear, $salt);
  51.  
  52. // create query
  53. $query = "INSERT INTO $table (username, password) VALUES ('$username', '$password')";
  54.  
  55. // execute query
  56. $result = mysql_query($query) or die ("<b> Registration unsuccessful.. <br /> </b> Raw error supplied by MySQL:<br /><br /> $query. ".mysql_error());
  57.  
  58. // print message with ID of inserted record
  59. //echo "New record inserted with ID ".mysql_insert_id();
  60. // print message with ID of created user
  61. echo "<b> Registration Successful! </b>";
  62. echo "<hr>";
  63. echo "New user created with ID ".mysql_insert_id(). "<br />";
  64. echo "<b>Username:</b> $username <br/>";
  65. echo "<b>Password:</b> $passwdclear <br/>";
  66. echo "<hr>";
  67. // close connection
  68. mysql_close($connection);
  69. }
  70.  
  71. ?>
  72. </body>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement