Thanks for talking a look๐
<?php
// Initialize Session
session_start();
// Check for previous authentication
if ( !isset($_SESSION['auth']) )
{
$loc = 'login.php?reason=login';
header("location:$loc");
exit;
}
$title = "Add a property";
include "../header.php";
include "../db.php";
$numbullets = $_POST["numbullets"];
if(!empty($Ref)) {
$Ref = addslashes($Ref);
$Name = addslashes($Name);
$Title = addslashes($Title);
$Location = addslashes($Location);
$Proptype = addslashes($Proptype);
$Price = addslashes($Price);
$No_bed = addslashes($No_bed);
$No_bath = addslashes($No_bath);
$Plotsize = addslashes($Plotsize);
$Descript = addslashes($Descript);
$numberofbullets = $_POST["nbullets"];
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$sql = "INSERT INTO properties SET Ref='$Ref', Name='$Name', Title='$Title', Location='$Location', Proptype='$Proptype', Price='$Price', No_bed='$No_bed', No_bath='$No_bath', Plotsize='$Plotsize', Descript='$Descript'";
$query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());
$PropertyID = mysql_insert_id();
for ($i = 0; $i < $numberofbullets; $i++)
{
$bullet_t = addslashes($_POST["bullet[$i]"]);
$sql2 = "INSERT INTO bullets SET bullet_t='$bullet_t', PropID='$PropertyID'";
$query2 = mysql_query($sql2)
or die("Cannot query the database.<br>" . mysql_error());
}
?>
<body bgcolor="#FFFFFF" text="#000000">
<meta HTTP-EQUIV="REFRESH" content="5; url=preupload.php?id=<?php echo $PropertyID;?>">
<?php
$j = 1;
for ($i = 0; $i < 3; $i++)
{
$bullet_t = $bullet_t.$j;
echo $bullet_t."<br>";
$j++;
}
} else {
?>
<table width="630" border="0" cellpadding="0" cellspacing="2">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="5">
<form name="addproperty" method="post" action="<?php echo $PHP_SELF; ?>">
<tr>
<td width="212" valign="top" class="bodytext"><b>Property Reference:</b></td>
<td valign="top" width="399" class="bodytext">
<input type="text" name="Ref" value="" maxlength="50">
</td>
</tr>
<tr>
<td valign="top" class="bodytext"><b>Name:</b></td>
<td valign="top" class="bodytext">
<input type="text" name="Name" value="" maxlength="50" size="50">
</td>
</tr>
<tr>
<td valign="top" class="bodytext"><b>Title:</b></td>
<td valign="top" class="bodytext">
<input type="text" name="Title" value="" maxlength="50" size="50">
</td>
</tr>
<tr>
<td valign="top" class="bodytext"><b>Location:</b></td>
<td valign="top" class="bodytext">
<input type="text" name="Location" value="">
</td>
</tr>
<tr>
<td valign="top" class="bodytext"><b>Property type:</b></td>
<td valign="top" class="bodytext">
<select name="Proptype">
<option>Apartment</option>
<option>Villa</option>
</select>
</td>
</tr>
<tr>
<td valign="top" class="bodytext"><b>Price:</b></td>
<td valign="top" class="bodytext">
<input type="text" name="Price" value="">
</td>
</tr>
<tr>
<td valign="top" class="bodytext"><b>N<sup>o</sup>. of Bedrooms:</b></td>
<td valign="top" class="bodytext">
<select name="No_bed">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</select>
</td>
</tr>
<tr>
<td valign="top" class="bodytext"><b>N<sup>o</sup>. of Bathrooms:</b></td>
<td valign="top" class="bodytext">
<select name="No_bath">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</select>
</td>
</tr>
<tr>
<td valign="top" class="bodytext"><b>Plot size:</b></td>
<td valign="top" class="bodytext">
<input type="text" name="Plotsize" value="">
</td>
</tr>
<tr>
<td valign="top" class="bodytext"><b>Description:</b></td>
<td valign="top" class="bodytext">
<textarea name="Descript" cols="65" rows="10"><?php echo $Descript; ?></textarea>
</td>
</tr>
<tr>
<td valign="top" class="bodytext"><b>Bullet points:</b></td>
<td valign="top" class="bodytext">
<?php
$bullet = array();
for ($i = 0; $i < $numbullets; $i++)
{
echo "<input type=\"text\" name=\"bullet[$i]\"><br>";
}
?>
</td>
</tr>
<tr align="center">
<td colspan="2"> <br>
<input type="submit" name="Submit" value="Add property">
<input type="hidden" name="nbullets" value="<?php echo $numbullets; ?>">
<input type="button" name="Cancel" value="Cancel" onclick="java_script_:history.back();return false;"/>
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</body>
</html>
<?php
}
?>