Guest User

Max PHP

a guest
Feb 26th, 2018
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. <!-- Först ett litet HTML-formulär: -->
  2.  
  3. <form action="Login.php" method="post" name="myForm" id="myForm">
  4.     <input type="text" placeholder="Enter username..." name="username" id="username">
  5.     <input type="password" placeholder="Enter password..." name="password" id="password">
  6.     <input type="submit" value="Register" name="register" id="register">
  7.     <input type="login" value="Log in" name="login" id="login">
  8. </form>
  9.  
  10. Sedan har vi min PHP, rätta mig gärna om jag har fel:
  11.  
  12. <?php
  13.  
  14. if(isset($_POST["register"])) {
  15.  
  16.     $username = $_POST["username"];
  17.     $password = $_POST["password"];
  18.  
  19.     $userData = array("username" => $username, "password" => password_hash($password, PASSWORD_DEFAULT));
  20.     $database = fopen("Database.txt", "w");
  21.     fwrite($database, serialize($userData));  
  22. }
  23.  
  24. ?>
Add Comment
Please, Sign In to add comment