Page 2 of 2

Re: stuck on multiple image update

Posted: Wed Oct 08, 2014 3:37 pm
by Celauran
I mean something like this

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'];

Re: stuck on multiple image update

Posted: Wed Oct 08, 2014 4:02 pm
by Celauran
Your code was initially

Code: Select all

<? $_SESSION['username']
Note the short opening tag (don't) and the missing echo statement. I fixed those in the code I posted, but if you didn't copy it all, that could be the cause.

Re: stuck on multiple image update

Posted: Wed Oct 08, 2014 4:17 pm
by Celauran
Just noticed there's no session_start() being called. Is it called elsewhere (via include) or is it missing?

Re: stuck on multiple image update

Posted: Wed Oct 08, 2014 4:45 pm
by Celauran
And you've checked on the form page that $_SESSION contains everything you're expecting it to? (print_r, var_dump, XDebug, whatever)