djscousey Posted December 10, 2006 Share Posted December 10, 2006 Hi all, What i am looking to do is, use radio buttons for the listener/s / viewers to select where they want there comment to go to.Here is the code i have upto now![code]<html><head><title>Summer Time Radio - Contact Us </title><style type="text/css"><!--p {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;}--></style></head><body><?php$mail = $_POST['Email'];$porukaa = $_POST['Message'];$poruka = str_replace("\r", '<br />', $porukaa);//START OF THANKS MESSAGE//you may edit $thanks message. this is a message which displays when user sends mail from your site$thanks = "<p align='left'><br><b>Your message has sucessfuly been sent<br></b><br><br>You will recive a copy of the message at your email address: <b>$mail</b><p>";//do not edit nothing below this line until comment (ME) say so if you don't have skills with PHP//END OF THANKS MESSAGEif (($_POST['destination']) == 'general' ) { $outgoing = "[email protected]"; } else (($_POST['destination']) == 'studio' ) { $outgoing = "[email protected]"; } elseif (($_POST['destination']) == 'djteam' ) { $outgoing = "[email protected]"; } if($_POST['submitform']) { $Name = $_POST['Name']; $Email = $_POST['Email']; $Message = $_POST['Message']; $outgoing = "[email protected]"; $require = $_POST['require']; $browser = $HTTP_USER_AGENT; $ip = $_SERVER['REMOTE_ADDR']; $dcheck = explode(",",$require); while(list($check) = each($dcheck)) { if(!$$dcheck[$check]) { $error .= "You have not filled the following field(s): <b>$dcheck[$check]</b>.<br>"; } } if ((!ereg(".+\@.+\..+", $Email)) || (!ereg("^[[email protected]]+$", $Email))){ $error .= "Wrong e-mail.<br>This e-mail address <b>$Email</b> - is not valid. Please enter a correct e-mail address."; } if($error) { echo $error; echo '<br><a href="#" onClick="history.go(-1)">Please try again.</a>'; } else {//START OF INCOMING MESSAGE (this message goes to your inbox)$message = "Name: $Name:E-mail: $EmailMessage: $Message-----------------------------Browser: $browserIP: $ip";//END OF INCOMING MESSAGE (this message goes to your inbox)$subject = "Message from Shout Box - Sent by $Name"; //subject OF YOUR INBOX MESSAGE sent to you$subject2 = "You have succesfully sent a message from www.summertimeradio.com"; //subject of OUTGOING MESSAGE - edit this//OUTGOING MESSAGE TEXT$message2 = "You have sent a message to <b>$outgoing</b>:-----------------------------From: $Name:E-mail: $Email Message: $Message-----------------------------";//END OF outgoing MESSAGEmail($outgoing,"$subject","$message","From: $Name <$Email>");mail($Email,"$subject2","$message2","From: <$outgoing>");echo "$thanks"; }}else{//this is contact form down here, please edit if you know what are you doing... or the contact form may not be working.echo '<form name="contactform" action="'.$PHP_SELF.'" method="post"><input type="hidden" name="require" value="Name,Email,Message"> <table width="444" align="center"> <tr> <td colspan="2" align="center"> </td> </tr> <tr> <td valign="top" align="right"><p><b>Name:</b></p></td> <td valign="top"> <input name="Name" size="30"> </td> </tr> <tr> <td valign="top" align="right"><p><b>E-mail:</b><p></td> <td valign="top"> <input name="Email" size="30"> </td> </tr> <tr> <td valign="top" align="right"><p><b>Message:</b></p></td> <td valign="top"> <textarea name="Message" rows="10" cols="30"></textarea> </td> </tr> <tr> <td colspan="2" align="center"><p align="center"><br> <input type="submit" value="Send" name="submitform"> <input type="reset" value="Reset" name="reset"></p> </form> </td> </tr> <tr> <form action="'.$PHP_SELF.'" method="post"> <td colspan="2" align="center"><p align="center"><br> <center> <h3> <u> <strong> Select An Option From below </strong> </u> </h3> <input type="radio" name="destination" id="1" value="biggus"> Contact Biggus <br> <input type="radio" name="destination" id="2" value="studio"> Contact The Studio <br> <input type="radio" name="destination" id="3" value="general"> General Enquiries <br> <input type="radio" name="destination" id="4" value="djteam"> Become A DJ </center> </td> </tr> </table></form>';}?></body></html>[/code]Any help would be much appreciated.Oh by the way, when i open the page with the above code in it, it shows up blankhttp://www.scouselandradio.com/contactformtest.phpThanks Link to comment https://forums.phpfreaks.com/topic/30144-radio-buttons-to-select-recipient/ Share on other sites More sharing options...
matto Posted December 10, 2006 Share Posted December 10, 2006 I think line 30 should read[code]elseif (($_POST['destination']) == 'studio' )[/code]and not [code]else (($_POST['destination']) == 'studio' )[/code]you might be better to use switch() Link to comment https://forums.phpfreaks.com/topic/30144-radio-buttons-to-select-recipient/#findComment-138629 Share on other sites More sharing options...
doni49 Posted December 10, 2006 Share Posted December 10, 2006 Or better yet, get rid of the conditional statement and use an array.[code]<?php$em[]="[email protected]";$em[]="[email protected]";$em[]="[email protected]";$em[]="[email protected]";?>[/code]Then if the user selects radio item #0 (you should change it so they start with #0 as opposed to #1) you just have to do the following:[code]<?php$toAddress = $em[POST['destination']];?>[/code] Link to comment https://forums.phpfreaks.com/topic/30144-radio-buttons-to-select-recipient/#findComment-138694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.