Jump to content


Photo

Difficult Forms Problem


  • Please log in to reply
2 replies to this topic

#1 Fearpig

Fearpig
  • Members
  • PipPipPip
  • Advanced Member
  • 195 posts

Posted 17 October 2006 - 03:01 PM

Hi guys,
This isn't a coding problem more of a method problem...

I've set up a page where people can request literature in volumes of 1, 25, 50 or a box. The page scans a database and for each bit of literature it creates a new set of radio buttons so that you can tick either 1, 25, 50 or box for each bit of literature.

I then wanted to submit this form as an e-mail to the person responsible. Unfortunately I don't know which variables are going to be passed to the processing page as that depends on which manuals are listed on the form (by which ones are in the database).

The form works correctly but I have no idea how to process it as of yet. Can anyone suggest a moethod or tutorial? This has been bugging me for a couple of days now. :-\

<p class="Body2">Documentation Request Form </p>
<form name="LiteratureRequestForm" method="post" action="ProcessingPage.php">

<?php 

$sql="SELECT * FROM BR_01_PRODF_0001 WHERE Product_Group = 'Literature'";
$result=odbc_exec($conn,$sql);
if (!$result)
       {exit("Error in SQL");}


echo "<table width=250 border=0 class='Body3'>\n";
echo "<tr><th class='Body2' align=center bgcolor=#CCCCCC><b>Manuals</b></th></tr>\n";
	
while (odbc_fetch_row($result)) 
		{
		$PartNo=odbc_result($result,"BR_PR_PARTNO");
		$Description=odbc_result($result,"BR_PR_StockFullDescr");
		echo "<tr><td><fieldset>
					<legend>$Description</legend>
					<input type='radio' name='$PartNo' value='1' id='1'>1
					<input type='radio' name='$PartNo' value='25' id='25'>25
					<input type='radio' name='$PartNo' value='50' id='50'>50
					<input type='radio' name='$PartNo' value='Box' id='Box'>Box
			</fieldset></td></tr>\n";
		}

echo "</table>\n";
?>

</form>

Any help would be appreciated.  ;D
"Whats wrong with the cat?" - Mrs Schrödinger

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 17 October 2006 - 04:06 PM

On your processing page, just process all of the values like this, that way you have no need to know what the values are:

<?php
echo "Please order me the following:\n";
foreach ($_POST as $part => $qty){
   echo "$part - $qty\n";
}
?>

Regards
Huggie

Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 Fearpig

Fearpig
  • Members
  • PipPipPip
  • Advanced Member
  • 195 posts

Posted 18 October 2006 - 08:09 AM

Huggiebear to the rescue!  ;D
Thank you. Now I just have to work out how to send that as an e-mail.
"Whats wrong with the cat?" - Mrs Schrödinger




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users