Simple email form

This is a discussion on "Simple email form" within the PHP Forum section. This forum, and the thread "Simple email form are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 15th, 2007, 14:41
Junior Member
Join Date: Jul 2006
Location: Maine
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Simple email form

My errors array works, but for some reason the email will not send?

PHP: Select all

<?php
// Check if the form has been submitted
if (isset($_POST['submitted'])) {

    
$errors = array(); //Initialize error array.
    
    //Check for email address
    
if (empty($_POST['EMAILADDR'])) {
    
$errors[] = 'You forgot to enter your email.';
    }
    
    
//Check for first name
    
if (empty($_POST['FIRST_NM'])) {
    
$errors[] = 'You forgot to enter your first name.';
    }
    
    
//Check for last name
    
if (empty($_POST['LAST_NM'])) {
    
$errors[] = 'You forgot to enter your last name.';
    }
    
    
//Check for address
    
if (empty($_POST['PRIMARY_ADR'])) {
    
$errors[] = 'You forgot to enter your address.';
    }
    
    
//Check for city
    
if (empty($_POST['CITY_NAME'])) {
    
$errors[] = 'You forgot to enter your city.';
    }
    
    
//Check for state
    
if (empty($_POST['STATE_CD'])) {
    
$errors[] = 'You forgot to enter your state or province.';
    }
    
    
//Check for zip
    
if (empty($_POST['ZIP_CD'])) {
    
$errors[] = 'You forgot to enter your zip.';
    }
    
    if (empty(
$errors)) { //If everything is ok.
    
    //send the email
    
    
$mailBody .= "Email Address: $EMAILADDR\n";
    
$mailBody .= "First Name: $FIRST_NM\n";
    
$mailBody .= "Last Name: $LAST_NM\n";
    
$mailBody .= "Address 1: $PRIMARY_ADR\n";
    
$mailBody .= "Address 2: $SECONDARY_ADR\n";
    
$mailBody .= "City: $CITY_NAME\n";
    
$mailBody .= "State: $STATE_CD\n";
    
$mailBody .= "Zip Code: $ZIP_CD\n";
    
$mailBody .= "Home Phone: $HOME_PHONE\n";
    
$mailBody .= "Work Phone: $WORK_PHONE\n";
    
$mailBody .= "Preferred Contact Method: $PREFER_CONTACT\n";
    
$mailBody .= "Type of Property Interested In: $PROP_INTERESTED_IN\n";
    
$mailBody .= "Additional Comments: $COMMENTS\n\r";

    
//add a from header
    
$mailHeaders .= "From: $who <$from>\n";
    
$mailHeaders .= "X-Sender: <$from>\n"
    
$mailHeaders .= "X-Mailer: PHP\n";
    
$mailHeaders .= "Return-Path: <$from>\n";
    
$mailHeaders .= "Content-Type: text/plain; charset=us-ascii \n"
    
    
mail("maverick25r@yahoo.com"$mailSubject$mailBody$mailHeaders);
    
    echo 
"<center>Thank You. Your inquiry has been received.";
    
    } else { 
// report the errors
    
echo 'The following errors occured:<br>';
    foreach (
$errors as $msg) { //Print each error.
        
echo" - $msg<br>\n";
        }
        echo 
'Please go back and try again.';
    }

} else {
}


?>
Reply With Quote

  #2 (permalink)  
Old Feb 15th, 2007, 17:42
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Simple email form

Have you tried a very simple one line email program?

If you're on a Windows system that's not an SMTP server, you may need to set that up in the php.ini, or you may need to authorise your mail forwarder to accep and forward emails from your system
Reply With Quote
Reply

Tags
email form

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
> Please Help With Simple Php Contact Form! dbh21 PHP Forum 7 Apr 21st, 2008 18:16
PHP email form not sending email Kurt PHP Forum 1 Oct 12th, 2007 04:26
Form submits to email via php, but email is blank!!?? DH1234 PHP Forum 2 Jun 18th, 2007 10:42
Email injection attack - simple protection method? EdgeWalker PHP Forum 1 Feb 15th, 2007 17:44


All times are GMT. The time now is 18:41.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43