PHP Form Validation with Redirect
Posted: Sat Dec 19, 2009 1:53 pm
Hello All,
As an IT engineer for a while now, I am now diversifying my skills and delving into the web developer world. I have so far implemented the following PHP form validation script (as sendmail.php) on my website but have a few expectations as well as issues. I have so far figured out everything myself except for one issue. FYI, my html form does a POST to this sendmail.php file:
Expectations:
1. Each of the fields listed has been made required which means users have to enter a value before they are sent to the thank you page otherwise they get an error page.
2. The value of every entered field should be included in the email delivered to my email address.
Current Issues:
1. Everything works as expected including email deliveries, but I need to remove the comma after each user entry in the email delivered.
How do I remove the comma after each user entry delivered to my email address? Any help will be appreciated.
Thanx.
As an IT engineer for a while now, I am now diversifying my skills and delving into the web developer world. I have so far implemented the following PHP form validation script (as sendmail.php) on my website but have a few expectations as well as issues. I have so far figured out everything myself except for one issue. FYI, my html form does a POST to this sendmail.php file:
Code: Select all
<?php
$firstname = $_REQUEST['firstname'] ;
$lastname = $_REQUEST['lastname'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$department = $_REQUEST['department'] ;
$howdidyouhear = $_REQUEST['howdidyouhear'] ;
$details = $_REQUEST['details'] ;
if (!isset($_REQUEST['email'])) {
header( "Location: http://www.mysite.com/error.html" );
}
elseif (empty($firstname) || empty($lastname) || empty($email) || empty($phone) || empty($department) || empty($howdidyouhear) || empty($details)) {
header( "Location: http://www.mysite.com/error.html" );
}
else {
//mail( "support@mysite.com", "Online Communications", $message, "From: $online@mysite.com" );
mail( "info@techworxs.com", "Online Communications", "First Name: $firstname \n, Last Name: $lastname \n, Phone: $phone \n, Department: $department \n, How Did You Hear About Us: $howdidyouhear \n, Details: $details \n", "From: $email" );
header( "Location: http://www.mysite.com/thanx.html" );
}
?>1. Each of the fields listed has been made required which means users have to enter a value before they are sent to the thank you page otherwise they get an error page.
2. The value of every entered field should be included in the email delivered to my email address.
Current Issues:
1. Everything works as expected including email deliveries, but I need to remove the comma after each user entry in the email delivered.
How do I remove the comma after each user entry delivered to my email address? Any help will be appreciated.
Thanx.