I have a script that grabs an id from a previous page, I then have some html which allows a user to submit some details on that id. The problem I am having is when I hit submit, the page returns, but the update query won't run and in the url of the page the id has pulled back some of the html fields from the html part of the script:
before I submit the url looks like so: supplierenquiryform.php?id=15
after submitting the url is: supplierenquiryform.php?enquirydetails=&submit=submit
id being the supplierid.
Here is the code (a lot of duplication has been removed in order to keep it nice and tidy):
//session details here
//checked the user is logged in
echo '<pre>' . print_r($_GET,true) . '</pre>';
if (isset($_GET['id'])) $id = intval($_GET['id']); //id being supplierid
$query = "select suppliers.supplierid, suppliers.town, suppliers.county WHERE suppliers.supplierid='" . mysql_real_escape_string($id) . "'";
//sort the rows of the database to be used
//now output some html based on conditions being met:
if($haircut == "true"){
echo "<p>The price for service1 is: £$service1price, type of rate: $service1type. Tick this box if you want to enquire on this service:<input type=\"checkbox\" name=\"service1selected\" value=\"true\"</p>";
echo "<p>Please select the number of people requiring this service:";
$display ='<select size="1" name="service1count">';
foreach(array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10+') as $value)
{
$selected = (isset($_POST['service1count']) && $_POST['service1count'] == $value ? ' selected="selected"' : '');
$display .= "<option value='$value'$selected>$value</option>\n";
}
$display .= '</select></p>';
echo $display;
}
//Now to setup the variables to go to the database table:
if(isset($_POST['submit']))
{
$_POST['username'] = $row ["username"];
$_POST['supplierid'] = $id;
if (!isset($_POST['service1selected'])) {
$service1selected = 'null';
}else{
$service1selected = $_POST['service1selected'];
}
$service1count = isset($_POST['service1count']) ? $_POST['service1count'] : "";
//do some validation of input and now the query:
$query5 = "INSERT INTO enquiry SET `supplierid` ='$id', `username` = '$username', //etc, etc
give messages to say that the database is updated ok
?>
<html>
<form>
<form name="form1" method="post" action="supplierenquiryform.php"
<tr><td>Please add any details or requests you would like to make:<BR> <TEXTAREA NAME="enquirydetails" value="<?php print isset($_POST["enquirydetails"]) ? $_POST["enquirydetails"] : "" ;?>"COLS=40 ROWS=6></TEXTAREA>
</td></tr>
<p><tr><td> </td><td><input name="submit" type="submit" value="submit"></td></tr></p>
</form>
</html>
As you can see I am echoing the query, but as it isnt doing that I can assume that the query isn't runing in the first place....
Any ideas?
Thanks,
G