Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title> Input page </title>
  4. </head>
  5. <body>
  6. <?php
  7. if($_POST) {
  8.     $username = "";
  9.     $password = "";
  10.     $database = "lettings";
  11.  
  12.     $mysqli = mysqli_connect("localhost", $username, $password, $database);
  13.  
  14.    
  15.     if((!empty($_POST['address'])) && (!empty($_POST['rent'])) && (!empty($_POST['bedrooms'])))                                    {$address = mysqli_real_escape_string($_POST['address']);
  16.         $rent = mysqli_real_escape_string($_POST['rent']);
  17.         $bedrooms = mysqli_real_escape_string($_POST['bedrooms']);
  18.     } else {
  19.         echo "You left a field blank";
  20.     }
  21. $query = mysqli_query($mysqli, "INSERT INTO contacts VALUES ('', '".$address."', '".$rent."', '".$bedrooms."'"));
  22.     mysqli_close($mysqli);
  23. } else {
  24.     //what to do in the event no post has been recieved at all, could be a blank submission, or could be the first loading of the page
  25. }
  26.  
  27. ?>
  28.  
  29. Input property data
  30.  
  31. <form method="post" action="">
  32. <input type="text" name="address" id="address" />
  33. <input type="submit" name="submit" value="Insert record" />
  34. </form>
  35. </body>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement