Jump to content

Problem with php generated html


genista

Recommended Posts

Hi all,

 

I have script with conditions in, on these conditions being met certain html is printed in my php. The problem I am haviing is getting the values from the html into my post array. The post array is working fine as I have tested it:

 

<?php
  if($service1 == "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;
} 
?>

 

As another note, when you tick a box or select something from a drop down and hit submit the page returns without the values you just entered, the checkboxes are empty etc.

 

Here is the html for the form element if that helps...

 

<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']); ?>">
<tr><td><input type="hidden" name="id" value="<?php echo($_GET['id']); ?>">
<p><input name="submit" type="submit" value="submit"></p>
</form>
</html>

 

 

Thanks,

 

 

G

Link to comment
https://forums.phpfreaks.com/topic/49281-problem-with-php-generated-html/
Share on other sites

Ok,

 

Here is the setting up of POST:

 

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

 

By all accounts I seem to have the checkbox and drop down output in the browser ok, the checkboxes look like when you check them and hit submit they are set to be inserted into the database, but it is not working which makes me suspect I have missed something, perhaps even in the form part...

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.