Advertisement

08.15.2008 at 08:56AM PDT, ID: 23651670 | Points: 500
[x]
Attachment Details

Add format checking to email form

Asked by guy4graphics in PHP Scripting Language

I have a simple php email script below. I want to require all fields be filled out before sending. Also I want to check that phone and email input is in the appropriate format.  

<?php
$to = "email@domain.com";
$from = "website@domain.com";
$name = $_REQUEST['name'] ;
$message = "Name: " .$name."\n\nBusiness or School Name:\n" .$_REQUEST['busname']. "\n\nAddress:\n" .$_REQUEST['address']."\n\nPhone:\n" .$_REQUEST['phone']."\n\nEmail:\n" .$_REQUEST['email'];
$headers = "From: $from\r\nReply-To: " . $_REQUEST['email'];
$subject = "DEMO request";

$fields{"Name"} = "Name";
$fields{"Email"} = "Email";

if (!empty($to) && !empty($from) && !empty($message) && !empty($headers) && !empty($subject)) {
  $send = mail($to, $subject, $message, $headers);
  if($send) {
    header("Location: http://www.domain.com/emailsent.php");
    exit;
  }
}

header("Location: http://www.domain.com/emailerror.php");
exit;

?>Start Free Trial
[+][-]08.15.2008 at 09:19AM PDT, ID: 22239481

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.15.2008 at 09:19AM PDT, ID: 22239482

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.15.2008 at 09:29AM PDT, ID: 22239567

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.15.2008 at 01:33PM PDT, ID: 22241551

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.15.2008 at 07:42PM PDT, ID: 22242865

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.15.2008 at 08:34PM PDT, ID: 22242970

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.16.2008 at 01:21AM PDT, ID: 22243494

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628