Forum Moderators: coopster
To have a form do different actions you need a way to, either, tell the form before hand what it is going to do then maybe write this into a hidden form variable or have a way for the user to select the action.
What are your 2 actions?
also you could use a regular button and then use javascript to send it to different scripts for processing but that isn't really the greatest idea depending on what you actually want to do.
So I'm thinking I have to make reference to whether this sendEmail button isSet and then execute code that will send an email with this info?
I know normally the "action" will point to say a mailParse script but I think I'll have to do all these 3 buttons in the same script? Though, another problem becomes how do I redirect it to a different page saying form completed or something...if-elsing the entire script and using echos to display the info would be dreadful.
I checked an online script, made some adjustments, but it isn't working. Basically, i'm checking if my submit button, named sendEmail was clicked, then it would execute the rest of this stuff.
<?php
if(isset($_POST['sendEmail'])){
$my_email = "Brian_Esmail@yahoo.com";
// This line prevents values being entered in a URL
if ($_SERVER['REQUEST_METHOD']!= "POST"){exit;}
$message = "";
// This line prevents a blank form being sent
while(list($key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$message = $message . "$key: $value\n\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}
$message = stripslashes($message);
$subject = "Sales Order";
$headers = "From: " . $_POST['email'] . "\n" . "Return-Path: " . $_POST['email'] . "\n" . "Reply-To: " . $_POST['email'] . "\n";
mail($my_email,$subject,$message,$headers);
}
?>