Advertisement
humpda

PHP_Form_Enter

Jul 30th, 2024 (edited)
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <html>
  2. <head>
  3.    
  4. </head>
  5.  
  6. <body>
  7. <!-- This creates the form. Pay attention to the "Name" of the textbox -->
  8.  
  9. <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
  10. Surname <input type="text" name="Surname"><p></p>
  11.  
  12. <input type="submit" name="submit" value="Save">
  13. </form>
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. <?php
  21.     $server = "localhost";
  22.     $username = "";
  23.     $password = "";
  24.     $db = "";
  25.  
  26.     $conn = mysqli_connect ($server, $username, $password, $db);
  27.    
  28. // if submit button is pushed, then take the form value (Surname) and run the insert query with it
  29.    
  30.     if (isset($_POST["submit"])) {
  31.         $Surname = $_POST["Surname"];
  32.         $query = mysqli_query($conn, "INSERT INTO ### Your table #### (Surname) VALUES ('$Surname')") or die(mysqli_error($conn));
  33.         $result = mysqli_query($conn,$query);
  34.        
  35.     }
  36.  
  37. mysqli_close($conn)
  38. ?>
  39.    
  40. </body>
  41.  
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement