Send Email Based On Selection (with File Upload)
I'm trying to create a page for my website, where students have to select 3 or less out of about 10 choices(multiple selection). They also need to upload a file below this. When th
Solution 1:
I dont have a sample code to give you, but roughly, it would be something like this:
<html><head><scripttype="text/javascript">functionmy_js_submit()
{
// check the email input fields that you care about.if(document.getElementById("email1").value != "" &&
document.getElementById("email2").value != "" &&
document.getElementById("email3").value != "")
{
document.forms["my_form"].submit(); //this will call the php where you do //emailing
}
else
{
alert("Please fill in all three emails");
}
}
</script></head><body><!-- submit_handler.php is where you send emails --><formid="my_form: method="post" action="submit_handler.php"><inputtype="text"id="email1" /><inputtype="text"id="email2" /><inputtype="text"id="email3" /><inputtype="text"id="message" /><buttononclick="my_js_submit();"> Submit </button></form></body></html>
PHP most basic code (name this file submit_handler.php):
<?php$to = $_POST['email1'] . "; " . $_POST['email2'] . "; " . $_POST['email3'];
$subject = "Email subject";
$message = $_POST['message'];
$from = "From: your_email@yourDomain.com";
mail($to,$subject,$message,$from); // The Mail function at work// Redirect your user to a page of your choice
header("Location: http://www.some_page.com");
?>
Post a Comment for "Send Email Based On Selection (with File Upload)"