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 开发者_C百科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 = "rbarbro@markonsolutions.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: jobs@markonsolutions.com";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
actuall page is located here
http://www.markonsolutions.com/captcha.php
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.
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_get_post.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.
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.
$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.
精彩评论