Wrox Programmer Forums
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 29th, 2007, 05:55 AM
Registered User
 
Join Date: Jan 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP Email

I was wondering if the format of an email could be changed for it to appear in a table or even with <br> in between? Where would i add this in the following code?

Code:
if (!isset($_POST['submit']) || $_SERVER['REQUEST_METHOD'] != "POST") {
    exit("<p>You did not press the submit button; this page should not be accessed directly.</p>");
} else {
    $exploits = "/(content-type|bcc:|cc:|document.cookie|onclick|onload|javascript|alert)/i";
    $profanity = "/*** REMOVED BY ADMINISTRATOR ***)/i";
    $spamwords = "/(viagra|phentermine|tramadol|adipex|advai|alprazolam|ambien|ambian|amoxicillin|antivert|blackjack|backgammon|texas|holdem|poker|carisoprodol|ciara|ciprofloxacin|debt|dating|porn)/i";
    $bots = "/(Indy|Blaiz|Java|libwww-perl|Python|OutfoxBot|User-Agent|PycURL|AlphaServer)/i";

    if (preg_match($bots, $_SERVER['HTTP_USER_AGENT'])) {
        exit("<p>Known spam bots are not allowed.</p>");
    }
    foreach ($_POST as $key => $value) {
        $value = trim($value);

        if (empty($value)) {
            exit("<p>Empty fields are not allowed. Please go back and fill in the form properly.</p>");
        } elseif (preg_match($exploits, $value)) {
            exit("<p>Exploits/malicious scripting attributes aren't allowed.</p>");
        } elseif (preg_match($profanity, $value) || preg_match($spamwords, $value)) {
            exit("<p>That kind of language is not allowed through our form.</p>");
        }

        $_POST[$key] = stripslashes(strip_tags($value));
    }

    if (!ereg("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,6})$",strtolower($_POST['email']))) {
        exit("<p>That e-mail address is not valid, please use another.</p>");
    }

    $recipient = "[email protected]";

    $subject = "You have a new order";

        $message = "Order Form: \n";
        $message .= "Title: {$_POST['title']} \n";
        $message .= "Forename: {$_POST['forename']} \n";
    $message .= "Surname: {$_POST['surname']} \n";
    $message .= "Home Address: {$_POST['haddress']} \n";
    $message .= "Town: {$_POST['htown']} \n";
    $message .= "Postcode: {$_POST['hpostcode']} \n";
    $message .= "Time At Current Address: {$_POST['htime']} Years {$_POST['htime2']} \n";
    $message .= "Billing Address: {$_POST['baddress']} \n";
    $message .= "Town: {$_POST['btown']} \n";
    $message .= "Billing Postcode: {$_POST['bpostcode']} \n";
    $message .= "Occupation: {$_POST['jobtitle']} \n";
    $message .= "Time With Present Employer: {$_POST['jobtime']} Years {$_POST['jobtime2']} \n";
    $message .= "Marital Status: {$_POST['marital']} \n";
    $message .= "Date of Birth: {$_POST['dob']}/{$_POST['dobm']}/{$_POST['doby']} \n";
    $message .= "Telephone: {$_POST['telephone']} \n";
    $message .= "Mobile: {$_POST['mobile']} \n"; 
    $message .= "Previous Address: {$_POST['paddress']} \n";
    $message .= "Town: {$_POST['ptown']} \n";
    $message .= "Postcode: {$_POST['ppostcode']} \n";
    $message .= "Time At Address: {$_POST['ptime']} Years {$_POST['ptimem']} \n";
    $message .= "Second Previous Address: {$_POST['paddress2']} \n";
    $message .= "Town: {$_POST['ptown2']} \n";
    $message .= "Postcode: {$_POST['ppostcode2']} \n";
    $message .= "Time At Address: {$_POST['ptime2']} Years {$_POST['ptimem2']} \n";
    $message .= "Accomodation Type: {$_POST['accom']} \n";
    $message .= "Occupation Type: {$_POST['occ']} \n"; 
    $message .= "Proof of Address: {$_POST['proof']} \n";  
    $message .= "Date of Birth: {$_POST['dproof']}/{$_POST['dproofm']}/{$_POST['dproofy']} \n";   
    $message .= "E-mail: {$_POST['email']} \n";
    $message .= "Country: {$_POST['country']} \n";
    $headers = "From: Sacranie-Mobiles.co.uk <$recipient> \n";
    $headers .= "Reply-To: <{$_POST['email']}>";

    if (mail($recipient,$subject,$message,$headers)) {
        echo "<p>Thank you! Your order has now been placed. We will be in touch shortly.</p>";
    } else {
        echo "<p>Sorry, there was an error and your mail was not sent. Please find an alternative method of contacting the webmaster.</p>";
    }
}
?>
Any help would be appreciated.
 
Old January 30th, 2007, 05:05 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hi,
Use like this

$message = '';
$message=$message.'<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
  <tr>
    <td width="100%" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td width="100%" align="center">&nbsp;</td>
  </tr>
</table>'

surendran
(Anything is Possible)
http://ssuren.spaces.msn.com
 
Old January 30th, 2007, 05:43 AM
Registered User
 
Join Date: Jan 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Surendran,

Thanks for your help. Really appreciate it. Just wanted to find out where to actually put this code within my code?






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to send email in php? j4uk3n PHP How-To 4 November 25th, 2006 02:06 AM
email php sunsetbay Beginning PHP 7 July 16th, 2005 01:57 PM
Email In php 4 philuk86 Beginning PHP 19 July 14th, 2004 05:31 PM
trouble with Email and PHP Tachyon Beginning PHP 3 May 26th, 2004 03:58 AM
Q. How do I access my email with PHP? richard.york PHP FAQs 0 April 8th, 2004 09:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.