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
Share on other sites

Maybe it's just too early in the day for me to understand, but what's the conncetion between the php script you posted, the html you posted, and the inability to detect values entered (as determined by code you haven't posted)?

Link to comment
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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.