Code: Select all
<?php
include "includes/connect-db.php";//database connection
// Grab the ID from the URL if one is specified
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
// If we don't have an ID, we can't do anything.
if (!isset($id)) {
header('Location: index.php'); // Or whatever. Don't submit a query if you don't have an ID.
}
$query = "SELECT * FROM privatelistings WHERE id = '$id';";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
mysql_close();
$username = $_SESSION['username'];
?>
<form action="process-edit-private-listings-info.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo "$row[id]" ?>">
<input type="hidden" name="submittedby" value="<?php echo $_SESSION['username'] ?>">
Title: <input type="text" name="listingtitle" value="<?php echo "$row[listingtitle]" ?>">
Car Make: <input type="text" name="make" value="<?php echo "$row[make]" ?>">
Car Model: <input type="text" name="model" value="<?php echo "$row[model]" ?>">
Exterior Colour: <input type="text" name="exteriorcolour" value="<?php echo "$row[exteriorcolour]" ?>">
Engine Size: <input type="text" name="enginesize" value="<?php echo "$row[enginesize]" ?>">
Fuel Type: <input type="text" name="fueltype" value="<?php echo "$row[fueltype]" ?>">
Year Registered: <input type="text" name="yearregistered" value="<?php echo "$row[yearregistered]" ?>">
Transmission: <input type="text" name="transmission" value="<?php echo "$row[transmission]" ?>">
Mileage: <input type="text" name="mileage" value="<?php echo "$row[mileage]" ?>">
Number of Doors: <input type="text" name="nodoors" value="<?php echo "$row[nodoors]" ?>">
Body Style: <input type="text" name="bodystyle" value="<?php echo "$row[bodystyle]" ?>">
Price: <input type="text" name="price" value="<?php echo "$row[price]" ?>"><br>
<label>Photo1</label>
<input type='hidden' name='size' value='350000'><input type='file' name='photo[]'><br>
<label>Photo2</label>
<input type='hidden' name='size' value='350000'><input type='file' name='photo[]'><br>
<input type="submit" value="Submit Listing">
</form>Code: Select all
//This gets all the other information from the form
$id = $_POST['id'];
$submittedby = $_POST['submittedby'];