Guest User

brugerregistrering

a guest
Aug 6th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2.     $server = "localhost";
  3.     $username = "username";
  4.     $password = "password";
  5.     $db = "awesome"
  6.    
  7.     $conn = new mysqli($server, $username, $password, $db);
  8.     if(!$conn){
  9.         die("Die hard: " . mysqli_connect_error());
  10.     }
  11. ?>
  12.  
  13. <html>
  14.     <head>
  15.     </head>
  16.     <body>
  17.         <form method="POST" action="">
  18.             <input type="text" name="username" placeholder="Username">
  19.             <input type="password" name="password" placeholder="Username">
  20.             <input type="submit" name="submit" value="LET ME IN!">
  21.         </form>
  22.     </body>
  23. </html>
  24. <?php
  25. if($_POST['SUBMIT']){
  26.    
  27.     $saltyness = sha1(md5($_POST['password']));
  28.     $sql = "INSERT INTO users (username, password) VALUES ('$_POST['username']', 'md5($_POST['password'].$saltyness)')";
  29.    
  30.     if($mysqli_query($conn, $sql)){
  31.         header('Location: http://www.google.dk/');  
  32.     } else {
  33.         echo "Error: " . $sql . mysqli_error($conn);
  34.     }
  35. }
  36. ?>
Add Comment
Please, Sign In to add comment