Using "if" in mail forms
Posted: Fri Sep 02, 2005 1:17 pm
I'm currently using a mail form to achieve a simple order form task. However, I want to be able to have an if statement to see if the payment method selected was PayPal or not and if it is to display something entirely different than if something else would have been selected.
Here is the mail form:
And here is the process form:
Thank you in advance.
Here is the mail form:
Code: Select all
<form action="processorder.php" method="post" >
<font face="Arial Rounded MT Bold" size="2" color="#860101">User Information</font><br>
<p><font size="1" face="Arial Rounded MT Bold">Desired Username:<br>
<input type="text" name="username" size="20" style="color:000000; background-color:FFFFFF; border-width: 1px; border-color:black"><br>
Password:<br>
<input type=password name="password" size="20" style="color:000000; background-color:FFFFFF; border-width: 1px; border-color:black"><br>
Confirm password:<br>
<input type=password name="password2" size="20" style="color:000000; background-color:FFFFFF; border-width: 1px; border-color:black"><br>
<br><font face="Arial Rounded MT Bold" size="2" color="#860101">Basic Information</font>
<p><font size="1" face="Arial Rounded MT Bold">First Name:<br>
<input type="text" name="name1" style="color:000000; background-color:FFFFFF; border-width: 1px; border-color:black"></font><font size="1" face="Arial Rounded MT Bold"><br>
Last Name:<br>
<input type="text" name="name2" size="20" style="color:000000; background-color:FFFFFF; border-width: 1px; border-color:black"><br>
Email Address:<br>
<input type="text" name ="email" style="color:black; background-color:FFFFFF; border-width: 1px; border-color:black"></font><br>
</font>
<font face="Arial Rounded MT Bold" size="1">Payment Method: </font> <br>
<select name="payment">
<option value="PayPal">PayPal</option>
<option value="Money Order">Money Order</option>
<option value="Chashier's Check">Cashier's Check</option>
</select><br><br>
<font face="Arial Rounded MT Bold" size="2" color="#860101">Billing Information</font><br><br>
<font face="Arial Rounded MT Bold" size="1">Street Address: </font> </font> <br>
<input type="text" name="street" size="35" style="color:black; background-color:white; border-width: 1px; border-color:black"><br>
<font face="Arial Rounded MT Bold" size="1">Country: </font> </font> <br>
<select name="country" size="1">
<option value="US">United States</option>
<option value="AF">Afghanistan</option>
//A lot more countries are posted, but there's no need for them here.
<br>
</select><br>
<font face="Arial Rounded MT Bold" size="1">City: </font> </font> <br>
<input type="text" name="city" size="20" style="color:black; background-color:white; border-width: 1px; border-color:black"><br>
<font face="Arial Rounded MT Bold" size="1">ZIP Code: </font> </font> <br>
<input type="text" name="zip" size="10" style="color:black; background-color:white; border-width: 1px; border-color:black"><br>
<font size="1">
<br>
<input type="submit" value="Submit" border-width: 1px; border-color:black"><br>
<br>
<font face="Arial Rounded MT Bold">All fields are required.
</font></font><br>
</p>
</form>Code: Select all
<?
$username=$_POST['username'];
$password=$_POST['password'];
$password2=$_POST['password2'];
$firstname=$_POST['name1'];
$lastname=$_POST['name2'];
$email=$_POST['email'];
$payment=$_POST['payment'];
$address=$_POST['address'];
$country=$_POST['country'];
$state=$_POST['state'];
$city=$_POST['city'];
$to="fxdesigning@gmail.com";
$message="This person has ordered a membership package:\n----------------------------------------------------------\nName: $firstname $lastname\nEmail: $email\n----------------------------------------------------------\n Desired username: $username\nPassword: $password\nConfirmed password: $password2\nPayment Method: $payment\n\nBilling Information: \nStreet Address: $street\nCountry: $country\nState: $state\nCity: $city\n ZIP Code: $zip\n ";
if(mail($to,"$firstname $lastname has purchased a membership!",$message,"From: $email\n")) {
echo "Thank you, $firstname, for purchasing a membership. The administrator will need to approve and set up your account. Please be patient and you will receive an email shortly on the confirmation of your account.<br><br>If you did not fill in all of the fields correctly, your order will not be processed correctly.";
} else {
echo "Sorry $firstname but there was a problem placing the order, please check you filled out the form correctly.";
}
?>