Jump to content

[SOLVED] Selecting Form Recipient


tpsilver10

Recommended Posts

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

Got it to work! Just added $provincestate="$provincestate"  8)

 

<?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);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.