Jump to content

Checkboxes and drop downs being omitted from POST


genista

Recommended Posts

Hi all,

 

I have a script which depending on certain conditions being met outputs some checkboxes and drop downs that look like this:

 

if($service1 == "true"){ 
   echo "<p>The price for Service 1 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; 
} 

 

Once these have been set I do some validation and then setup my post array upon submit:

 

if(isset($_POST['submit']))    
{  
$_POST['username'] = $row ["username"]; 
$_POST['supplierid'] = $id; 

if (!isset($_POST['service1selected'])) {    
    $service1selected = 'null';    
}else{  
    $service1elected = $_POST['service1elected'];  
   
      }  
$service1count = isset($_POST['service1count']) ? $_POST['service1count'] : "";  

 

Now we insert the data into the database and then some html for the form submit etc:

 


    $query5 = "INSERT INTO enquiry SET `supplierid` ='$id', `username` = '$username', //etc, etc 

give messages to say that the database is updated ok 
?> 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title><?php print $page ?>
</title>
</head>
<form name="form1" method="post" action="supplierenquiryform.php?id=<?php echo($_GET['id']); ?>">
<p><input name="submit" type="submit" value="submit"></p>
</form>
</html>

 

 

The problem I am having is when you hit submit, only the supplierid, the username and values for the checkboxes are being inserted. In other words if I select something from the drop down when the page is submitted the query is empty of this data.

 

Any ideas?

 

Thanks,

 

G

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.