开发者

PHP code when it come to sending a mail to different parties depending on the radio button selection

I don't really understand PHP and now I need to make our contact us for information form go to a different email address depending on their campus selection.

The page can be found on http://www.aisj-jhb.com/Admissions/ContactUs.html

If they select Johannesburg campus the mail goes to a different person and if they select Pretoria Campus the mail goes to someone else. I know it is something to do with the parameters, but once more it is greek or code to me.

Here is a extract from the code. Note I didn't do the original PHP code, but can edit it slightly.

$siteaddress ="http://www.aisj-jhb.com"; 
$sitename = "AISJ"; 
$EmailFrom = "AISJ"; 
$EmailTo = "lvdalen@aisj-jhb.com";
$Subject = "AISJ-Requesting Information";

Now I know my email addresses go into the $EmailTo = section.

Can someone please help me with the parameters?

Thank you开发者_JAVA百科

Liesl


Something like this should work. Try it and let's see.

   $siteaddress ="http://www.aisj-jhb.com"; 
   $sitename = "AISJ"; 
   $EmailFrom = "AISJ"; 
   $Subject = "AISJ-Requesting Information"; 
   switch($_POST["Campus"]){
      case "Johannesburg":
      $EmailTo = johannesburg@aisj-jhb.com;
      case "Pretoria":
      $EmailTo = pretoria@aisj-jhb.com;
      default: //In case neither radio button is selected
      $EmailTo = lvdalen@aisj-jhb.com;
   };

Edit: Switch case helps to control the flow process based on what the posted value of the radio button "campus" is. In Case its Johannesburg, send to the Jo'burg mail. In case its pretoria, do similarly. If neither of the two, send to lvdalen.

Meanwhile, you can also edit this to ensure that the person selects one or the other:

<input type="radio" value="Johannesburg" name="Campus" checked="checked">


in contact form in value field use email address like Which campus are you interested in?

<strong class="text_red">*</strong>
  <br>
      Johannesburg Campus:
      <input type="radio" name="Campus" value="johannesburg@aisj-jhb.com">
  <br>
      Pretoria Campus:
      <input type="radio" name="Campus" value="pretoria@aisj-jhb.com"><br></td>

then in action file write 
<?php $EmailTo = $_POST['Campus'];
?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜