Advertisement
ZacharyVincze

Untitled

Jul 19th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. <html>
  2.     <h1>Register</h1>
  3.     <form action="register.php" method="post">
  4.         Username: <input type="text" name="rusername" /><p>
  5.         Password: <input type="password" name="rpassword" /><p>
  6.         Confirm Password: <input type="password" name="confirmpwd" /><p>
  7.         <input type="submit" name="submit" value="Register" />
  8.     </form>
  9. </html>
  10.  
  11. <?php
  12.  
  13. ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
  14.  
  15. session_start();
  16.  
  17. $rusername = $_POST['rusername'];
  18. $rpassword = $_POST['rpassword'];
  19. $confirmpwd = $_POST['confirmpwd'];
  20.  
  21. $servername = '127.0.0.1';
  22. $loginusername = '';
  23. $loginpassword = '';
  24. $dbname = '';
  25.  
  26. if ($rusername && $rpassword && $confirmpwd) {
  27.    
  28.     if ($rpassword == $confirmpwd) {
  29.         $connect = new mysqli($servername, $loginusername, $loginpassword, $dbname);
  30.    
  31.         if ($connect->connect_error) {
  32.             die("Connection failed: " . $conn->connect_error);
  33.         }
  34.    
  35.         $query = "INSERT INTO user (id, username, email, password) VALUES (NULL, ?, NULL, ?)";
  36.    
  37.         $stmt = $connect->prepare($query);
  38.         $stmt->bind_param("ss", $rusername, $rpassword);
  39.        
  40.         $stmt->execute();
  41.        
  42.         $stmt->close();
  43.         $connect->close();
  44.     } else {
  45.         echo "Confirm password did not match...";
  46.     }
  47. } else {
  48.     echo "Please fill in all the fields...";
  49. }
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement