Advertisement
Guest User

Untitled

a guest
Feb 28th, 2024
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | Source Code | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <?php
  10. $USR = $_POST["username"];
  11. $PWD = $_POST["password"];
  12. $PWD1 = $_POST["password1"];
  13.  
  14. if ($PWD == $PWD1) {
  15.  
  16. } else {
  17. echo "<h1>Not the same password given</h1>";
  18. die();
  19. };
  20.  
  21. $DSN = 'mysql:host=localhost;dbname=test';
  22. $pdo = null;
  23. $dbusr = "root";
  24. $dbpwd = "";
  25. $SQL = 'INSERT INTO `users`(`username`, `password`) VALUES (":USR",":PWD")';
  26.  
  27. try {
  28. $pdo = new PDO($DSN, $dbusr, $dbpwd);
  29. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  30. } catch (PDOException $e) {
  31. echo 'Connection failed: ' . $e->getMessage();
  32. }
  33.  
  34. $stmt = $pdo->prepare($SQL);
  35.  
  36. $stmt->execute(array($USR,$PWD));
  37.  
  38. $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
  39.  
  40. $pdo = null;
  41. $stmt = null;
  42. ?>
  43.  
  44. <h1>Results: <?php
  45.  
  46. if ($SUCC) {
  47. echo 'Successful!';
  48. } else {
  49. echo 'Unsuccessful.';
  50. }
  51. ?></h1>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement