Blank data submitted using List in form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
happy_tapper
Forum Newbie
Posts: 5
Joined: Mon Sep 18, 2006 5:51 am
Location: UK

Blank data submitted using List in form

Post by happy_tapper »

Please could someone possibly help.

I am creating an Offline ordering system for the company i work for, which basically lets them create purchase orders when the main system or network fails. I have it working OK but i need to add an option for Pack Sizes. I have created this as a SELECT list in an HTML form, which retrieves the various pack sizes from the products table; it should then submit the chosen pack size to a temporary table, which is displayed on the order page. However, it seems to be submitting a null value.

My original code was :

Code: Select all

<form method="POST" action="add.php">
     Quantity :
         <input type="text" name="qty" size="2">
         <input type="hidden" name="prodnum" value="<?php echo $prodnum ?>"><br><br>
       
	   Pack Size :

		<select name="packsize" size="1" method = "POST" action = "add.php">
  		<option value="$pack1"><?php echo "Pack 1 : ".$pack1; ?></option>
  		<option value="$pack2"><?php echo "Pack 2 : ".$pack2; ?></option>
		</select>
$pack1 and $pack2 are taken from the products table and submitted as packsize, which is picked up in the next page as $packsize.

I have got around it by using the below, which asks the user to manually enter the pack size; i would like to get away from this method if possible.

Code: Select all

<form method="POST" action="add.php">
     Quantity :
         <input type="text" name="qty" size="2">
         <input type="hidden" name="prodnum" value="<?php echo $prodnum ?>"><br><br>
       
	   Pack Size :
		
		<input type="text" name="packsize" size = "2"><br />
		<?php  echo "Enter <b>".$pack1."</b> for Pack 1" ?><br />
		<?php
			// Check for a second pack size - else display a message.
			if ($pack2 == "") {
			echo "<b>This product is only in Singles.</b><br>";
			}
			elseif ($pack2 != "") {
		?>
		<?php  echo "Enter <b>".$pack2."</b> for Pack 2"  ?><br /><br />
	   	<?php } ?>
	   <center><input type="submit" name="Submit" value="Add to Order"></center>
       </form>
I am a noob, just so you know, but i do try, honestly i do... plus this is my first post...ever

I would be gratefull of any help.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

<option value="$pack1"><?php echo "Pack 1 : ".$pack1; ?></option>
$pack1 is just text, it's not within a php block (and not echo'ed)
User avatar
happy_tapper
Forum Newbie
Posts: 5
Joined: Mon Sep 18, 2006 5:51 am
Location: UK

Post by happy_tapper »

Thank you very much, that did the trick.

A simple thing as echo'ing the option value... :oops:

Again, thanks for your time.
Post Reply