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
stumped passing radio button info to php mailer
Old 09-09-2008, 06:19 PM stumped passing radio button info to php mailer
Junior Talker

Posts: 2
Name: Thomas
Trades: 0
I'm stumped trying to figure out how to add some radio button fields into a clients php/html form. not really my area of expertise and the form isn't quite how i would have made it but we're kind of stuck with it now.

Anyways here is how it is setup now:

The php part of the form submits info to his email using this format:
$mail_message= $mail_message . "Rental Choice: " . $typerental1. "\n";
$mail_message= $mail_message . "Rental Choice: " . $typerental2. "\n";
$mail_message= $mail_message . "Rental Choice: " . $typerental3. "\n";
$mail_message= $mail_message . "Rental Choice: " . $typerental4. "\n";

Right now it is only passing: "Rental Choice" to his email but need the user to be able to check one or all of 4 different radio buttons and have it pass whether the button is checked or unchecked using the above type of coding.

Here is the coding for the html part. I've been playing around with different ways to try and pass this info and the latest code included below with typerental 2 is my latest experiement at trying to figure out how to make it work but to no avail. Obvioulsy not know what I am doing, any help would be appreciated and would probably answer this forever and into the future lol.

<td align="right" valign="top" colspan="2">*Rental Choice: (Choose all that apply)</td>
<td align="left" valign="top" colspan="2"><input type="radio" name="typerental1" value="CellPhone" />Cell Phone
<input type="radio" name="typerental2" value="GPS" <?if ($typerental2 == "GPS") { ?> CHECKED <?}?>> GPS
<input type="radio" name="typerental3" value="blackberry" /> Blackberry
<input type="radio" name="typerental4" value="satphone" /> Satellite Phone
thomaswhiteeagl is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-09-2008, 10:36 PM Re: stumped passing radio button info to php mailer
Extreme Talker

Posts: 246
Trades: 3
Radio buttons aren't the best choice for choosing multiple options. I suggest using check boxes. Depending on your method of submitting the form, you would access the value of each checkbox with $_GET or $_POST.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
CouponGuy is offline
Reply With Quote
View Public Profile
 
Old 09-09-2008, 11:41 PM Re: stumped passing radio button info to php mailer
prasanthmj's Avatar
Experienced Talker

Posts: 42
Name: Prasanth
Trades: 0
You have to use check boxes to let multiple selections (or a list box with multiple selection)
code below:

HTML Code:
<td align="right" valign="top" colspan="2">*Rental Choice: (Choose all that apply)</td>
<td align="left" valign="top" colspan="2">
<input type="checkbox" name="typerental[]" value="CellPhone" />Cell Phone
<input type="checkbox" name="typerental[]" value="GPS" <?if ($typerental2 == "GPS") { ?> CHECKED <?}?>> GPS
<input type="checkbox" name="typerental[]" value="blackberry" /> Blackberry
<input type="checkbox" name="typerental[]" value="satphone" /> Satellite Phone
PHP Code:
$typerental $_POST['typerental'];

for (
$i=0;$i count($typerental); $i++)
{
   
$mail_message .= $typerental;

The following links also would help:
multiple check box question

and
checkbox in a PHP form processor
prasanthmj is offline
Reply With Quote
View Public Profile
 
Old 09-10-2008, 12:06 AM Re: stumped passing radio button info to php mailer
Junior Talker

Posts: 2
Name: Thomas
Trades: 0
Thanks, guys. I kinda thot it would be a quick and easy answer but in the interim I kept on digging around and fingered it out for myself maybe my answer isn't the cleanest but it works.

HTML:

<td align="right" valign="top" colspan="2">*Rental Choice: (Choose all that apply)</td>
<td align="left" valign="top" colspan="2">
<input type="checkbox" name="typerental[]" value="Cell Phone">Cell Phone
<input type="checkbox" name="typerental[]" value="GPS"> GPS
<input type="checkbox" name="typerental[]" value="Blackberry"> Blackberry
<input type="checkbox" name="typerental[]" value="Satphone"> Satphone

PHP:
if ( isset($_REQUEST['Submit']) ) {
$trent = $_REQUEST['typerental'];
foreach ( $trent as $value ) {
$mail_message = $mail_message . "Rental Choice: " . $value. "\n";
}
thomaswhiteeagl is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to stumped passing radio button info to php mailer
 

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 1.07557 seconds with 12 queries