genista Posted April 30, 2007 Share Posted April 30, 2007 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 Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 30, 2007 Share Posted April 30, 2007 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)? Quote Link to comment Share on other sites More sharing options...
genista Posted April 30, 2007 Author Share Posted April 30, 2007 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... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.