Jump to content

Recommended Posts

Hi

 

Sorry if I've miseed this one in the forums - have been searching for some time and nothing really matches the problem I'm having.

 

I want to create a form that emails query to a different email address depending on what radio button is selected.

 

I'm finding that my submit button isn't working. It's the first time that I've tried to do this particular form and have only been building php for a week or so, so please go easy on me ;) (I do have proper training booked) This is the first time my submit hasn't worked so I'm wondering if the code that controls the email array means that I have to change the submit code? Just a guess.

 

I've got the following html code:

 

<form method="POST" action="housekeeping_mailer.php">

                <input name="Name" type="text" id="Name" size="20"\><br /><br />

             

              <b>Email Address:</b><br />

                <input name="Email" type="text" id="Email" size="20"\>

         

              <p> <b>Mobile Number:</b><br />

                <input name="Mobile" type="text" id="Mobile" size="20"\>

             

              <p> <b>Dealer(FCS) Code:</b><br />

                <input name="FCS" type="text" id="FCS" size="20"\>

             

              <p> <b>Vehicle Registration:</b><br />

                <input name="Reg" type="text" id="Reg" size="20"\>

              <p>

           

                <input type="radio" name="Query" value="Logistics" checked\>

                <b>Logistics Query </b></p>

           

                <input type="radio" name="Query" value="HPI"\>

                <b>HPI Query </b></p>

              <p>

                <input type="radio" name="Query" value="V5"\>

                <b>V5 Query </b></p>

             

              <p align="left">

                <textarea name="Textarea" cols="50" rows="5">Type your query here...</textarea>

                <br /><br /><input type="submit" value="Submit" name="submit"></form>

 

and the following php code:

 

<?php

  if(isset($_POST['submit'])) {

  $name = $_POST["Name"];

  $email = $_POST["Email"];

  $mobile = $_POST["Mobile"];

  $fcs = $_POST["FCS"];

  $reg = $_POST["Reg"];

  $subject = $_POST["Query"];

  $logistics = $_POST["Logistics"]; //logistics

  $HPI = $_POST["HPI"]; //hpi

  $V5 = $_POST["V5"]; //v5

  $message = $_POST["Textarea"];

 

  $subject = "Housekeeping - $subject Query";

  $emailgroup = $_POST["Query"];

  $emailmessage = "Contacts Name: $name\nEmail Address: $email\nQuery Type: $subject\nQuery is: $message";

  $email1 = "[email protected]";

  $email2 = "[email protected]";   

  $email3 = "[email protected]"; 

 

  if ($emailgroup == "logistics")

  {$messagesent = mail($email1, $subject, $emailmessage,"From: $email\r\n" . "Reply-To: $email");

  include "./querysent.shtml";}

 

  elseif

      ($emailgroup == "HPI")

  {$messagesent = mail($email2, $subject, $emailmessage,"From: $email\r\n" . "Reply-To: $email");

  include "./querysent.shtml";}

 

  elseif ($emailgroup == "V5")

  {$messagesent = mail($email3, $subject, $emailmessage,"From: $email\r\n" . "Reply-To: $email");

  include "./querysent.shtml";}

 

  else include "./queryfailed.shtml";

?>

 

 

Thanks in advance!

 

 

Ok, I'm now at a point where my queryfailed.shtml page is coming up when I submit the form. This appears to show it's working but could anyone help with getting the email to actually send. I haven't changed the code except for adding the missing } at the bottom of the code.

Ok, I got flustered with this code and decided to redo it a bit to see how it worked. It had to do with your Query/radio buttons, so I fixed that and cleaned it up a little. Here's what I got:

<form method="POST" action="housekeeping_mailer.php">
                <input name="Name" type="text" id="Name" size="20"\><br /><br />
             
               <b>Email Address:</b><br />
                <input name="Email" type="text" id="Email" size="20"\>
           
              <p> <b>Mobile Number:</b><br />
                <input name="Mobile" type="text" id="Mobile" size="20"\>
             
              <p> <b>Dealer(FCS) Code:</b><br />
                <input name="FCS" type="text" id="FCS" size="20"\>
             
              <p> <b>Vehicle Registration:</b><br />
                <input name="Reg" type="text" id="Reg" size="20"\>
              <p>
             
                <input type="radio" name="query" value="Logistics"\>
                <b>Logistics Query </b></p>
           
                <input type="radio" name="query" value="HPI"\>
                <b>HPI Query </b></p>
              <p>
                <input type="radio" name="query" value="V5"\>
                <b>V5 Query </b></p>
             
              <p align="left">
                <textarea name="Textarea" cols="50" rows="5" >Type your query here...</textarea>
                 <br /><br /><input type="submit" value="Submit" name="submit"><input type="hidden" value="submit" name="submitted"></form>

<?
$group = $_POST['query']; 

    $name = $_POST["Name"];
   $email = $_POST["Email"];
   $mobile = $_POST["Mobile"];
   $fcs = $_POST["FCS"];
   $reg = $_POST["Reg"];
   $subject = $_POST["Query"];
   $Logistics = $_POST["Logistics"]; //logistics
   $HPI = $_POST["HPI"]; //hpi
   $V5 = $_POST["V5"]; //v5
   $message = $_POST["Textarea"];

if(isset($_POST['submit'])) {
   $subject = "Housekeeping - $subject Query";
   $emailgroup = $_POST["Query"];
   $emailmessage = "Contacts Name: $name\nEmail Address: $email\nQuery Type: $subject\nQuery is: $message";
   $email1 = "[email protected]";
   $email2 = "[email protected]";   
   $email3 = "[email protected]";   
   

switch($group) {
	case "Logistics":
		$messagesent = mail($email1, $subject, $emailmessage,"From: $email\r\n" . "Reply-To:$email");
		include "./querysent.shtml";
		break;
	case "HPI":
		$messagesent = mail($email2, $subject, $emailmessage,"From: $email\r\n" . "Reply-To: $email");
	        include "./querysent.shtml";
		break;
	case "V5":
   			$messagesent = mail($email3, $subject, $emailmessage,"From: $email\r\n" . "Reply-To: $email");
		include "./querysent.shtml";
		break;
	default:
                        include "./queryfailed.shtml";
		break;
}
}
?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.