views:

588

answers:

4

I'm trying to create am online application for some job postings we have at work.

I have the form items (text boxes / drop downs /etc) portion set up and i have the send email with a captcha part setup

im unclear on how to "call" the value of something like

<select name="education">
     <option value="None">None</option>
     <option value="HighSchool">HighSchool</option>
     <option value="BA/BS">BA/BS</option>
     <option value="MA/MS">MA/MS</option>
     <option value="MBA">MBA</option>
     <option value="Ph.D">Ph.D</option>
     <option value="Other">Other</option>
    </select>

In the mail portion of the code how do insert the value of the education dropdown into the body?

            $to = "[email protected]";
      $subject = "Test mail";
      $message = "Hello! This is a simple email message.";
      $from = "[email protected]";
      $headers = "From: [email protected]";
      mail($to,$subject,$message,$headers);
      echo "Mail Sent.";

actuall page is located here

http://www.markonsolutions.com/captcha.php

+1  A: 

You need to have the user submit the form, and then get the value from the $_POST["education"] (or $_GET["education"]) fields depending upon what method you choose.

Mark P Neyer
+3  A: 

Try:

$message = "Education: " . $_POST["education"];

Make sure to sanitize your form posts though, otherwise people could inject JavaScript or whatever they want into your form.

John Rasch
+2  A: 

It seems like you might be confused about how PHP works. PHP is a serverside language, which means that you can't receive the values of those fields in PHP until a page is loaded from the server. Usually this happens when the user presses the submit button. Now, the page that is loaded might incidentally be the same page that the form is on, but it's not a requirement.

Once a page with a form is submitted, in the request data, it sends along all the values that the user chose. You can access these values in PHP using $_GET and $_POST arrays, which you can find more about here:

http://www.tutorialspoint.com/php/php%5Fget%5Fpost.htm

Sorry if I misunderstood your question, but I think its useful to clarify this for people who visit that might be confused about the difference between serverside and clientside.

Kai
+1  A: 

$message = "Here goes my mail body: Education selected was: {$_POST['education']}

Here is another one: {$_POST['Jobname']} ";

In my opinion, you should capture all individual post, do some checks and create a little template.

$body = sprintf("Name: %s
Job: %s
", $name
 , $phone);

Well, i think i have told too much about the subject of the this topic.

Ismael