Hi,
I have an insert function working, but im looking for a redirect to the original page upon completion of the insert, that will then then display the 1 row inserted message on page. I want to keep the insert file and the form page separate. I'm aware that I can use a header to direct me back, but how to I carry the message across?
Form: create_property.php
<?php session_start();
/* This file is used to create new properties
*/
//Includes
include 'include\template\default\main\header.php';
include 'admin\connection.php';
?>
<!--HTML form for adding a property -->
<div id="main">dsfsdfdsf
<form action="/include/functions/insert.php" method="post">
<label>Price: </label><input type="text" name="price"><br/>
<select name="p_type">
<option value="House">House</option>
<option value="Bungalow">Bungalow</option>
</select>
<label>Number of Bedrooms: </label><input type="text" name="beds"><br/>
<label>Price: </label><input type="text" name="price"><br/>
<br/>
<input type="submit" name="add_property">
</form>
</div>
<?php
//Footer include
include 'include\template\default\main\footer.php';
?>
insert.php
<?php
/*This file scripts the SQL to insert into the DB
*/
//Includes
include '..\..\admin\connection.php';
if(isset($_POST['add_property']))
{
//Insert Property
$sql="INSERT INTO property (type, bedrooms, price)
VALUES
('$_POST[p_type]','$_POST[beds]','$_POST[price]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
}
?>