Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Sending form fields built on the fly
Old 07-10-2006, 11:59 AM Sending form fields built on the fly
Junior Talker

Posts: 1
Trades: 0
Hi,

I created a 2 part form where a user selects the number of employees on the first page, which determines the number of form field sets on the next page. I'm stuck on how to then send that data in the resulting email.

The form fields are created on the second page with this:
$i = 1;
while ($i <= $_POST['empno']) {
echo "<tr><td align=right>Employee ";
echo $i;
echo " Name/ID:</td><td><input name=emp";
echo $i;
echo " size=20></td><td align=right>Date of Birth:</td><td><input name=emp";
echo $i;
echo "dob size=12></td></tr>";


$i = $i + 1;
}


So it produces the form fields emp1 and emp1dob, emp2 and emp2dob, etc. depending on the number of employees selected.

How do I then set variables to place in the body message for the form field names and values?

This doesn't work:
$i = 1;
While($i <= $empno) {
$emp[$i]=$_POST['emp'.$i];
$emp[$i]dob=$_POST['emp'.$i.'dob'];
$i = $i + 1;
}

Am I close? Thanks!
souloyster is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-10-2006, 01:56 PM Re: Sending form fields built on the fly
Webmaster Talker

Posts: 626
Trades: 0
Place this code within the <form></form> tags of the second page:

PHP Code:
<!-- Import Variables from previous page -->
<?php    
   
foreach($_POST as $key => $value) { 
    echo 
"<input type='hidden' name='$key' value='".htmlentities($valueENT_QUOTES)."'>"
    } 
?>
That should work by creating a hidden field with the appropriate variable name and the value should be carried through.

Is that what you are looking for?
jim.thornton is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Sending form fields built on the fly
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21094 seconds with 12 queries