IHateMyselfx

segitseg

Oct 14th, 2023
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <?php
  2. $host_ = "localhost";
  3. $usernameZ = "root";
  4. $passwordZ = "";
  5. $dbname = "teszter";
  6.  
  7. $conn = new mysqli($host_,$usernameZ,$passwordZ,$dbname);
  8. if($conn->connect_error)
  9. {
  10.     die("connectionerror");
  11. }
  12.  
  13.  
  14. if($_SERVER["REQUEST_METHOD"]=="POST")
  15. {
  16.     $userZ = $_POST["name"];  //kiszeded a form-bol az adatokat fontos hogy az inputnak adj name="" erteket mert itt arra kell hivatkoznod
  17.     $psdZ = $_POST["psd"];
  18.     $user_add = "INSERT INTO proba (valami1, valami2) VALUES ('$userZ', '$psdZ')";          //megirod az sql lekerdezest
  19.     $conn->query($user_add);         //query-el futtatsz le parancsokat az adatbazison
  20.     echo $user_add;
  21. }
  22.  
  23.  
  24. ?>
  25. <!DOCTYPE html>
  26. <html lang="en">
  27. <head>
  28.     <meta charset="UTF-8">
  29.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  30.     <title>Document</title>
  31. </head>
  32. <body>
  33. <form action="index.php" method="POST">
  34.     <label for="name">name</label>
  35.     <input type="text" name="name" placeholder="name">
  36.  
  37.     <label for="psd">password</label>
  38.     <input type="text" name="psd" placeholder="password">
  39.     <input type="submit" value="POST">
  40. </form>
  41.  
  42.    
  43. </body>
  44. </html>
Advertisement
Add Comment
Please, Sign In to add comment