Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title> Input page </title>
- </head>
- <body>
- <?php
- if($_POST) {
- $username = "";
- $password = "";
- $database = "lettings";
- $mysqli = mysqli_connect("localhost", $username, $password, $database);
- if((!empty($_POST['address'])) && (!empty($_POST['rent'])) && (!empty($_POST['bedrooms']))) {$address = mysqli_real_escape_string($_POST['address']);
- $rent = mysqli_real_escape_string($_POST['rent']);
- $bedrooms = mysqli_real_escape_string($_POST['bedrooms']);
- } else {
- echo "You left a field blank";
- }
- $query = mysqli_query($mysqli, "INSERT INTO contacts VALUES ('', '".$address."', '".$rent."', '".$bedrooms."'"));
- mysqli_close($mysqli);
- } else {
- //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
- }
- ?>
- Input property data
- <form method="post" action="">
- <input type="text" name="address" id="address" />
- <input type="submit" name="submit" value="Insert record" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement