tpsilver10 Posted May 3, 2007 Share Posted May 3, 2007 Hey there, I'm trying to build a form which allows me to send the information to a recipient based on a drop down menu. So if the users selects 'Ontario' it sends the the Toronto person. Or Quebec. etc... This is what I have, but it just sends straight to the 'else' e-mail. <?php include("global.inc.php"); $errors=0; $error="The following errors occured while processing your form input.<ul>"; pt_register('POST','firstname'); pt_register('POST','lastname'); pt_register('POST','email'); pt_register('POST','telephone'); pt_register('POST','preferred'); pt_register('POST','provincestate'); pt_register('POST','comments'); $comments=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $comments);if($errors==1) echo $error; else{ $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/")); $provincestate="provincestate"; $message="firstname: ".$firstname." lastname: ".$lastname." email: ".$email." telephone: ".$telephone." preferred: ".$preferred." provincestate: ".$provincestate." comments: ".$comments." "; $message = stripslashes($message); if ($provincestate == 'ON'){ mail("[email protected]","Pacesetter Feedback",$message,"From: PacesetterTravel.com"); } elseif ($provincestate == 'QC'){ mail("[email protected]","Pacesetter Feedback",$message,"From: PacesetterTravel.com"); } else { mail("[email protected]","Pacesetter Feedback",$message,"From: PacesetterTravel.com");} $make=fopen("admin/data.txt","a"); $to_put=""; $to_put .= $firstname."|".$lastname."|".$email."|".$telephone."|".$preferred."|".$provincestate."|".$comments." "; fwrite($make,$to_put); ?> Any tips? EDIT: I just realised that I'm defining the $provincestate variable as 'provincestate', there for it's not ON or QC...but I'm not sure how to call it from the form... <html><select name="provincestate" size="1" id="province" class="formstyles"> <option selected="selected"> </option> <option>ON</option> <option>QC</option> <option>Etc</option> <option>NOT APPLICABLE</option> </select></html> Link to comment https://forums.phpfreaks.com/topic/49875-solved-selecting-form-recipient/ Share on other sites More sharing options...
tpsilver10 Posted May 3, 2007 Author Share Posted May 3, 2007 Got it to work! Just added $provincestate="$provincestate" <?php include("global.inc.php"); $errors=0; $error="The following errors occured while processing your form input.<ul>"; pt_register('POST','firstname'); pt_register('POST','lastname'); pt_register('POST','email'); pt_register('POST','telephone'); pt_register('POST','preferred'); pt_register('POST','provincestate'); pt_register('POST','comments'); $comments=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $comments);if($errors==1) echo $error; else{ $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/")); $provincestate="$provincestate"; $message="firstname: ".$firstname." lastname: ".$lastname." email: ".$email." telephone: ".$telephone." preferred: ".$preferred." provincestate: ".$provincestate." comments: ".$comments." "; $message = stripslashes($message); if ($provincestate == 'ON'){ mail("[email protected]","Pacesetter Feedback",$message,"From: PacesetterTravel.com"); } elseif ($provincestate == 'QC'){ mail("[email protected]","Pacesetter Feedback",$message,"From: PacesetterTravel.com"); } else { mail("[email protected]","Pacesetter Feedback",$message,"From: PacesetterTravel.com");} $make=fopen("admin/data.txt","a"); $to_put=""; $to_put .= $firstname."|".$lastname."|".$email."|".$telephone."|".$preferred."|".$provincestate."|".$comments." "; fwrite($make,$to_put); ?> Link to comment https://forums.phpfreaks.com/topic/49875-solved-selecting-form-recipient/#findComment-244685 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.