Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. He means this. Say I am making a register.
  2.  
  3.  
  4. <?php
  5.  
  6. include 'dbstuff.php';
  7.  
  8. if(!$_POST['submit']){
  9. echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">";
  10. echo "<form 'action=".$_SERVER['PHP_SELF']."' method=\"POST\">";
  11. echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td></tr>";
  12. echo "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td></tr>";
  13. echo "</form></table>";
  14. }else {
  15. $username = $_POST['username'];
  16. $password = $_POST['password'];
  17.  
  18. $newpassword = md5($password);
  19.  
  20. if(isset($_POST['username'])){
  21. if(isset($_POST['password'])){
  22. $ins = "INSERT INTO `users` (`username`, `password`) VALUES ('$username', '$newpassword')";
  23. $res = mysql_query($ins);
  24.  
  25. echo "You have successfully registered under ".$_POST['username']."!";
  26. }else {
  27. echo "You must enter a password.";
  28. }
  29. }else {
  30. echo "You must enter a username.";
  31. }
  32.  
  33. }
  34.  
  35. ?>
  36.  
  37. Notice why I put $newpassword and not $password? Because $newpassword is converted to an MD5 hash so that it is encrypted upon it's placing in the new row that will be created corresponding to the new user. This will prevent other people with access to the database to see the password from the users.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement