PHP Email Form is not Emailing

HI,
I made a PHP email form and i was wondering if i did it
correct. I try to send a email but for some reason it wont work
here is the PHP code:
<?php
$emailSubject = 'Computer Question!';
$webMaster = '[email protected]';
$nameField = $_POST ['name'];
$phoneField = $_POST ['phone'];
$emailField = $_POST ['email'];
$questionField = $_POST ['question'];
$body = <<<EOD
<br><hr><br>
Name: $name <br>
Phone: $phone <br>
Email: $email <br>
Question: $question <br>
EOD;
$headers = "From: $email\r\n";
$headers .="Content=type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
/* Results Rendered as HTML */
$theResults = <<<EOD
?>
Here is the Email form:
:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post"
action="Contact form 505 test 2.php">
<table width="70%" border="1" cellpadding="6">
<tr>
<th width="16%" scope="col"><div align="right">
<label for="name">Name:</label>
</div></th>
<th width="84%" scope="col"><div align="left">
<input name="name" type="text" id="name" size="35"
maxlength="60" />
</div></th>
</tr>
<tr>
<th scope="row"><div align="right">
<label for="phone ">Phone Number</label>
</div></th>
<td><div align="left">
<input name="phone " type="text" id="phone " size="35"
maxlength="13" />
</div></td>
</tr>
<tr>
<th scope="row"><div align="right">
<label for="email">Email:</label>
</div></th>
<td><div align="left">
<input name="email" type="text" id="email" size="35"
maxlength="40" />
</div></td>
</tr>
<tr>
<th scope="row"><div align="right">
<label for="question">Question:</label>
</div></th>
<td><div align="left">
<textarea name="question" cols="26" rows="8"
id="question"></textarea>
</div></td>
</tr>
<tr>
<th scope="row"> </th>
<td><label for="Send Email"></label>
<input type="submit" name="Send Email" id="Send Email"
value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
Any help would be appreciated!
thanks

.oO(jumpman310)
> I made a PHP email form and i was wondering if i did it
correct. I try to send
>a email but for some reason it wont work here is the PHP
code:
Next time please be more specific. "won't work" isn't really
helpful.
Anyway, the first thing to fix is the error reporting on your
testing
server, obviously it's not configured properly. In your
php.ini these
directives have to be set:
error_reporting = E_ALL|E_STRICT
display_errors = on
You should get some notices from your script. After fixing
those issues,
you should also read about header injection and how to
prevent it. Your
script is vulnerable and can be abused for sending spam. Also
consider
to use a class like PHPMailer to make things more secure and
convenient.
Some further notes about your form markup:
* It's very good that you make use of labels for your form
controls, but
in some cases the IDs of these controls contain spaces, which
is not
allowed.
* You don't really need a label for a submit button.
* Consider to drop all those div elements in the table
headers - you
don't need them. Use CSS to style the labels the way you
want, e.g.
form th {text-align: right}
I also use this:
label:hover {outline: 1px dotted #666}
* Check the markup of the "Name" row. The 'scope' attribute
is incorrect
and the form control should be inside a 'td', not a 'th'.
Micha

Similar Messages

  • Interactive forms will not email out

    I have the Acrobat 8 pro program and cannot email out interactive forms that I have created in Live Cycle Designer. They always hang up in the email program and I get an error message indicating that the connection with my server was "unexpectedly terminated". I work at home and have a DSL connection. I have tried increasing the server timeout and it has not helped. I have also experienced a number of other issues I have seen posted on the Acrobat Reader forums, such as memory leak, max. CPU usage,etc. since acquiring the Acrobat 8 Pro program, first by downloading the free trial, then purchasing and registering my software disk. Is there a fix for the email issue? I need to be able to send these forms out- I am attempting to send them out to one recipient at a time, not distribute them "en-masse". Any help appreciated.

    What is issuing the timeout message, Acrobat or the mail program? The email program and Norton Internet Security program
    What is it, exactly? It tells me that the mail was not sent because the connection with the server has been unexpectedly terminated; After adjusting the timeout on the email program options, the email is now being sent, but it is stripped of the PDF attachment AND is jumbled and duplicated 45-50 times. I sent the documents to a colleague to test it yesterday and he received 45 emails from me (all with the same exact time stamp) and they were all gibberish code and none had the PDF file attachment; I sent another test to an alternate email of my own and received 50 copies, void of the text body of the email as well as void of the attachment.
    What is the e-mail program?Outlook exprress
    With reference to your comment
    "By the way, e-mail CANNOT be guaranteed to work for all recipients, it is not suitable for professional use,"
    I am using the Acrobat 8 PROFESSIONAL program which has the "Submit via Email" option. The program "read me" states that this function in the program is specifically designed for the distribution and collection of data. According to the way the program is advertised and information contained in the program itself, it does not indicate that I am attempting to utilize the program to perform tasks that it is not designed to do. All Adobe information on this program is printed with reference to the program being utilized in a workplace/professional environment.

  • My email forms are not working with one website, but are for my others, all hosted by the same host....

    I cannot get my email forms to work for one of my live sites... They work when I published to business catalyst, now they do not. I have contacted the host and they cannot seem to see the issue, as the other sites they host for me, the forms work just fine... Please help, I am about to punch a hole through my computer...
    -Travis

    Whatever happened, it sounds like you need to reset your phone. As contacts and messages seem to have gone they would be lost anyway unless they were on the SD card and/or backed up using Nokia Suite.
    I'd suggest you reset the phone by dialling *#7370# followed by the security code which is 12345 by default (is asked). The phone will reset and you should be able to use it again afterwards.
    Let us know what happens..
    Click on the blue Star Icon below if my advice has helped you or press the 'Accept As Solution' link if I solved your problem..

  • Email form submit not sending to GoDaddy and Yahoo hosted email accounts

    I have two sites that have contact forms and for some reason I addresses hosted by go daddy and yahoo aren't getting the form submissions. One site is http://www.lashwaxboutique.com/contact.html the other site I can't share at the moment. Are there known issues with godaddy and yahoo mails? They have worked in previous versions of muse.

    I have a similar issue. I don't know if it is just go daddy and yahoo. I think it is all submit to email. Here is the thread.
    Re: muse broken update - not emailing pdf forms from website

  • Email Form With No Email Address

    Hello,
    I am trying to get more information on how I can help my
    clients reduce
    spam. I've normally built my forms by using:
    <form action=http://www.domain.com/cgi-sys/formmail.pl...
    <input type="hidden" name="recipient"
    value=[email protected]>
    but this obviously puts the email address right in the hands
    of the spam
    crawlers.
    Is there a way to eliminate having to show your recipient
    value in the HTML?
    Can someone tell me how this is done?
    Thanks in advance.

    "Nancy O" <[email protected]> wrote in
    message
    news:fdoo9p$516$[email protected]..
    > I use this one from DB Masters. It's a php formmailer
    script that
    conceals
    > email address inside the script - not in the form.
    >
    http://www.dbmasters.net/index.php?id=4
    >
    >
    > --Nancy O.
    > Alt-Web Design & Publishing
    > www.alt-web.com
    >
    >
    >
    > "TxWebdesigner" <[email protected]>
    wrote in message
    > news:fdojm4$if$[email protected]..
    > > Hello,
    > >
    > > I am trying to get more information on how I can
    help my clients reduce
    > > spam. I've normally built my forms by using:
    > >
    > > <form
    action=http://www.domain.com/cgi-sys/formmail.pl...
    > >
    > > <input type="hidden" name="recipient"
    value=[email protected]>
    > >
    > > but this obviously puts the email address right in
    the hands of the spam
    > > crawlers.
    > >
    > > Is there a way to eliminate having to show your
    recipient value in the
    > HTML?
    > > Can someone tell me how this is done?
    > >
    > > Thanks in advance.
    > >
    Note this utility has just been updated today to 4.5 (was in
    beta) and
    includes a number of optional Form SPAM Control fields
    (hidden field, timer,
    CAPTCHA e.g.) if you find your form being used to send SPAM.
    Jim

  • When I create a calendar invitation on my iphone 4s and select a recipients "work" email address (Lotus Notes email address), the invite actually is sent to that persons iphone calendar vs. their Lotus Notes calendar

    When I send an invite from my iPhone 4s to my husband's work email address (not synced to his iPhone), the invite appears in his iPhone calendar and not his work email. 

    You state your husband has Good installed on his iPhone to synchronize with his work Lotus Notes.  Good synchronizes email, calendars, and contacts.
    http://www.good.com/support/lotus-domino.php
    Good uses a separate email inbox, contact list, and calendar within the Good app (ughhh).  But Good is designed to look very similar to the native iOS apps.  Is it possible your husband is viewing his Good calendar instead of the native iOS Calendar app?  I think with default settings the Good calendar has a red status bar instead of the usual blue/gray.

  • Email form and not XML

    Hello,
    How do I set the email button so that the form is mailed and not the data in XML format?
    Thank you.

    Hi Chris,
    Thanks so much for the excellent advice. It was a breeeze once I knew what to do, and clicking on the XML Source Tab brought me right to the line of code that needed to be changed. I uploaded the form to our web site and sent it to myself and the PDF arrived instead of XML.
    I do have another question. I can't find settings for Reader Extensions anywhere. I'm guessing this isn't an issue as long as the form is on our web site, but from what you say it seems like if I email the form to our users and they have it on their desktop and try to send it it won't go unless I have the RE settings correct.
    I'm a novice and trying to learn so I appreciate your patience.
    Thanks.

  • Muse contact form is not sending emails.

    Muse site contact form is not sending emails.  I perform a form check using this link http:/my_site.com/scripts/form_check.php.  It is giving the message that SQL configuration problem.
    Please help to solve this.

    I posted a very similar issue into the bugs forum. "
    Email form submit not sending to GoDaddy and Yahoo hosted email accounts"
    I have tested the emails across various forms and it works but does not using the Muse form widget. I strongly believe this is an Adobe Muse issue and needs further support from Adobe. In the mean time I have begun using Jot Form on my sites (jotform.com)

  • How Do I Insert 2 Email Forms in a Flash Site

    Let's say I wanted to have 2 email forms in a flash site. One to go to one inbox and another to go to another inbox. That's easy enough to do by editing the PHP, but not the AS3. The following code works for the first email form, but not the 2nd because of duplicate actions.  So my question is, "What do I need to edit in the following AS3 code to get it to submit a second form?"  Thanks.
    [as]
    stop(); 
    contact_name.text = contact_email.text = contact_subject.text =  contact_message.text = message_status.text = ""; send_button.addEventListener(MouseEvent.CLICK, submit);
    reset_button.addEventListener(MouseEvent.CLICK, reset); 
    var timer:Timer;
    var var_load:URLLoader = new URLLoader;
    var URL_request:URLRequest = new URLRequest( "send_email.php" );
    URL_request.method = URLRequestMethod.POST; 
    function submit(e:MouseEvent):void
        if( contact_name.text == "" || contact_email.text == "" ||
            contact_subject.text == "" || contact_message.text == "" )
            message_status.text = "Please complete all text fields.";
        else if( !validate_email(contact_email.text) )
            message_status.text = "Please enter a valid email address.";
        else
            message_status.text = "sending...";
            var email_data:String = "name=" + contact_name.text
                           + "&email=" + contact_email.text
                           + "&subject=" + contact_subject.text
                           + "&message=" + contact_message.text;
            var URL_vars:URLVariables = new URLVariables(email_data);
            URL_vars.dataFormat = URLLoaderDataFormat.TEXT;
            URL_request.data = URL_vars;
            var_load.load( URL_request );
            var_load.addEventListener(Event.COMPLETE, receive_response );
    function reset(e:MouseEvent):void
        contact_name.text = contact_email.text = contact_subject.text =
        contact_message.text = message_status.text = "";
    function validate_email(s:String):Boolean
        var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
        var r:Object = p.exec(s);
        if( r == null )
            return false;
        return true;
    function receive_response(e:Event):void
        var loader:URLLoader = URLLoader(e.target);
        var email_status = new URLVariables(loader.data).success;
        if( email_status == "yes" )
            message_status.text = "Success! Your message was sent.";
            timer = new Timer(500);
            timer.addEventListener(TimerEvent.TIMER, on_timer);
            timer.start();
        else
            message_status.text = "Failed! Your message was not sent.";
    function on_timer(te:TimerEvent):void
        if( timer.currentCount >= 10 )
            contact_name.text = contact_email.text = contact_subject.text =
            contact_message.text = message_status.text = "";
            timer.removeEventListener(TimerEvent.TIMER, on_timer);
    [/as]

    Wouldn't you just change instance names completely?

  • Security settings for email form

    I created a form with LCD 8 with the intention of having different departments able to just complete the forms and click the "Submit by email" I was able to get the form to email as a PDF but I do not like that the user can change the form and I tried to set the security settings but when I did that the form would not email.
    I really do not want the user to have to enter a password if possible.

    Ok, if you are using LiveCycle Designer to make the form, I recommend
    the LiveCycle Designer forum (LiveCycle is part of the name of many
    different things). For other questions about Acrobat, including forms
    made in Acrobat, I recommend the Acrobat Windows forum.
    Good luck,
    Aandi Inston

  • Email form guru needed

    Hi,
    Any help greatly appreciated from an email form guru!
    I have a email form that returns emails to my address - but no others. It is laden with a load of content and HTML. I have checked spam filters and junk inboxes and I'm at a loss as to why this would be happening. I have set up numerous email accounts but only two accounts I have had for ages work. Other emails from the same server are received by the same email host - so I don't think they are being blocked, unless that happens automatically when there is a large volume of html in the email. This still doesn't explain why I get the emails and no one else does.
    Thanks in advance!
    See http://www.recruitercritic.com/smarterhire-std-exit-survey.htm which goes to a php send form with the following code:
    Smarterhire exit interview:
    First name
    {$_POST['First']}
    Last name
    {$_POST['Last']}
    Title
    {$_POST['Title']}
    Organisation
    {$_POST['Organisation']}
    Contact number
    {$_POST['Contact_number']}
    email
    {$_POST['email']}
    Date joined
    {$_POST['When_joined']}
    Last date
    {$_POST['Last_day']}
    Survey requested by
    {$_POST['survey_recip']}
    Recipient email contact
    {$_POST['recip_email']}
    Why joined
    {$_POST['why_joined']}
    Role expectations
    {$_POST['Role_expectations']}
    Role expectations differences
    {$_POST['Role_differences']}
    $message_body
         Reasons for leaving:
    Was remuneration a consideration in your leaving?
    {$_POST['rem']}
    Was redundancy...
    $message_body
         Job satisfaction:
    Was the support and resources required to fill your role adequate?
    {$_POST['Support_radio']}
    The following....
    $message_body
         Exiting employees departure information:
    Which of the following best describes your departure?
    {$_POST['New_destination']}
    If applic....   End;       $headers  = "MIME-Version: 1.0\r\n";      $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";      $headers .= "From: ".$_POST['email']." <".$_POST['first'].">\r\n";       mail($to, $subject, $message_body, $headers);      header ("Location: /exit-int-thankyou.htm");      exit;  }else{      header ("Location: /smarterhire-std-exit-survey.htm");      exit; }  ?>

    Ok, I am trying to understand the problem.
    If I understand correctly the php script works, it is just an issue of trying to send it to other email addresses.  Is that correct?
    You have been able to successfully reconfigure the php script to send to at least 1 other email address.  Correct?
    When you try some other email addresses they email from the form handler doesn't arrive.  Correct?
    Are the other email addresses at another domain than recruitercritic.com?
    Can you send to more than one address at the same time?  If so what happens when you send to the original email address and one of the others?
    Well, since the script works with the original email, and you are able to successfully modify the script to direct to at least one other email address then it seems that the script is working just fine.  I don't think you have a code issue.  I don't know how heavily formatted the emails are but it is possibly that the emails are getting blocked by the spam filters on the receiving email servers.  You might check http://mxtoolbox.com/ and see what your mail server IP is and what it's reputation is.  If it is on some blacklists that could account for it being blocked by filters on other servers. If that is the case then you should work on getting off any blacklists you are on.

  • Forum uses userid not email

    Hello,
    I have a pretty old Oracle userid (which is not an email address). If I modify my profile (in opn or otn) I see my login "seeburge" and my email address ([email protected]). But when i am in the forum control panel, I only see my login. And obviously (since I dont get watch alerts) oracle is trying to send to my login-id instead of my email address.
    This is not a good advertising for SSO and portal capabilities :(
    Gruss
    Bernd

    I have spoken to two Adobe people who have told me that the forums are indeed sending me emails, but I'm not getting them.
    They say this is probably a problem with me ISP. This confuses me. It doesn't make sense to me that I would get email from other parts of adobe.com such as [email protected] or [email protected], but not [email protected]
    Also, if it is my ISP, shouldn't I still see those emails on my mac.com webmail service? The email is sent directly to mac and then my Mail client fetches the emails.
    Also, if it's my ISP, wouldn't I be able to see the emails on my smartphone. It doesn't use my ISP at all.
    If anyone has insight as to what organization I should try to contact (Apple and Time/Warner are both megaliths that I'd rather not tilt at without reason), could you let me know?

  • PHP email form with Validation - not working

    Hello;
    I am new to using php. I usually use coldfusion or asp but this site requires me to write in php. I have a form I am trying to get to work and right now.. it doesn't do anyhting but remember what you put in the fields. It doesn't want to send, and it won't execute the validation script for the fields that are required. Can anyone help me make this work? I'm confused and a definate newbie to PHP.
    Here is my code:
    <?php    
                  $PHP_SELF = $_SERVER['PHP_SELF'];   
                  $errName    = "";   
                  $errEmail    = "";
                  $errPhone    = "";        
                  if(isset($_POST['submit'])) {        
                          if($_POST["ac"]=="login"){            
                        $FORMOK = TRUE;    // $FORMOK acts as a flag. If you enter any of the conditionals below,                             // it gets set to FALSE, and the e-mail will not be sent.
                        // First Name           
                        if(preg_match("/^[a-zA-Z -]+$/", $_POST["name"]) === 0) {               
                            $errName = '<div class="errtext">Please enter you name.</div>';               
                            $FORMOK = FALSE;           
                        // Email           
                    if(preg_match("/^[a-zA-Z]\w+(\.\w+)*\@\w+(\.[0-9a-zA-Z]+)*\.[a-zA-Z]{2,4}$/", $_POST["email"]) === 0) {                                                    $errEmail = '<div class="errtext">Please enter a valid email.</div>';               
                            $FORMOK = FALSE;           
                        // Phone           
                        if(preg_match("/^[a-zA-Z -]+$/", $_POST["phone"]) === 0) {               
                            $errPhone = '<div class="errtext">Please enter your phone number.</div>';               
                            $FORMOK = FALSE;           
                        if($FORMOK) {               
                                $to = "[email protected]";  
                                $subject = "my. - Contact Form";                  
                                $name_field = $_POST['name'];               
                                $email_field = $_POST['email'];               
                                $phone_field = $_POST['phone'];
                                $city_field = $_POST['city'];
                                $state_field = $_POST['state'];               
                                $message = $_POST['comment'];                
                                $message = "               
                                Name: $name_field               
                                Email: $email_field
                                Phone: $phone_field   
                                City: $city_field   
                                State: $state_field               
                                Message: $message";                
                                $headers  = 'MIME-Version: 1.0' . "\r\n";               
                                $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";                
                                // Additional headers               
                                $headers .= 'To: <[email protected]>' . "\r\n";               
                                $headers .= '[From] <$email_field>' . "\r\n";                
                                // Mail it               
                                mail($to, $subject, $message, $headers);                
                                header("Location: thankyou.php")
                                // I have no idea what these next 3 lines are for. You may just want to get rid of them.                   
    ini_set("sendmail_from","[Send from]");
    ini_set("SMTP","[mail server]");
    mail($to, $subject, $message, $headers);
                                } else {               
                                echo "Error!";              
                        ?>
    <form method="post" action="<?php $PHP_SELF ?>" id="commentForm">
    <input name="name" size="40" value="<?php echo $_POST["name"]; ?>" type="text">
                         <?php  if(isset($errName)) echo $errName; ?>
    <input name="email" size="40" value="<?php echo $_POST["email"]; ?>"  type="text">
            <?php  if(isset($errEmail)) echo $errEmail; ?>
    <input name="phone" size="40" value="<?php echo $_POST["phone"]; ?>" type="text" id="phone">
            <?php  if(isset($errPhone)) echo $errPhone; ?>
    <input name="city" size="40" value="<?php echo $_POST["city"]; ?>" type="text" id="city">
    <input name="state" size="40" value="<?php echo $_POST["state"]; ?>" type="text" id="state">
    <textarea name="comment" cols="30" rows="10" id="comment"><?php echo $_POST["comment"]; ?></textarea>
    <input type="submit" value="Submit" name="submit" class="contact-submit" />
    </form>
    It seems pretty simple.. but it's not working at all. I would also like this page to submit to it's self, and when it actually does send an email, to just make the form disappear and replace it with the thank you text instead of sending you to another page. I also do not need to use an smtp server, it goes directly to the network server when sent.
    I'm really sorry to ask all of this, I'm trying to learn this language and need to make this work.
    Thank you for anyones help in advance.

    .oO(BarryGBrown)
    > I have a php file which generates an email from a form
    in a website I have
    >designed. I just want to make some areas of the final
    generated email in bold
    >text. I know if people have plain text only selected in
    their email client they
    >won't see the bold text, but at least it will reach a
    certain percentage of
    >users.
    You can't do bold text in a normal email. Plain text is just
    that -
    plain text. For anything more you need HTML. _If_ you should
    need it.
    Usually plain text serves pretty well and is the most
    efficient way.
    > the line in question is -
    >
    > $body ="Booking request details from website:\n\n";
    >
    > I have tried putting  and ,
    syntax is used in some forum software, but besides that it
    has
    no meaning whatsoever.
    >inside the inverted commas, outside
    >etc, plus tried different declarations within the
    <head>, nothing works! What
    >am I doing wrong?
    You would have to create an entire HTML email with all the
    required
    headers and boundaries. Quite difficult to do by hand with
    PHP's mail()
    function.
    > I am a beginner with this php stuff, please be kind!
    Then you should start simple with plain text. There are some
    classes out
    there which make it easy to generate text and HTML emails
    (phpmailer for
    example), but you should be familiar with PHP coding if you
    want to use
    them.
    Micha

  • Urgent help - MUSE email form not working - PLEASE HELP

    HI to all!!
    I'm having a big issue here with Adobe Muse cc 7.0
    I have my personal domain www.shepherdtextiles.com
    and third party host (here in China which is 72e.net (and yes, got all php and so on requirements Adobe Muse needs)
    I follow carefully all steps to add a simple contact form, adding first [email protected] and changing it to my personal hotmail when I saw it wasn't working to try if with hotmail could work, but didn't.
    I have checked the Muse PHP Diagnostics  and as you can see the mail one failed.....
    I used first the simple contact form that comes with Muse and later I used one from museresources.com but none of them seemed to work
    I'm just guessing that something is not well setup on my server because I just follow all steps Adobe mentioned and I watched many videos where people do it very simple.
    The error I get on my website when I click on submit button is "The server encountered an error"
    There is NO error when I export to html or warnings, just exports fine.
    PLEASE HELP
    Many many thanks!
    Vic

    I'M having a similar problem with my Muse website Formally hosted by GoDaddy. The contact me widget does not send an email when you click submit button. Normally, it accepts with a green check mark in another screen. It does not do that. The submit just turns black when clicked, but nothing else happens
    THe he regular email works. I am able to send and receive. It just does not work with the contact widget

  • Posting contact form to variable email address PHP

    Hi all, another one!
    I want the email address to be the hidden variable in the form below - variable higlighted in Red. What would I put for "$to ="?
    Any help would be appreciated.
    Tom
    <?php
    if (array_key_exists('send' , $_POST)) {
              // mail processing script
              // remove escape characters from POST array
    if (PHP_VERSION < 6 && get_magic_quotes_gpc()) {
      function stripslashes_deep($value) {
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
        return $value;
      $_POST = array_map('stripslashes_deep', $_POST);
    $to = '';
              $subject = '';
              //list expected fields
              $expected = array('name', 'email', 'comments');
              //set required fields
              $required = array('name', 'comments');
              //create empty array for any missing fields
              $missing = array();
              // assume that there is nothing suspect
              $suspect = false;
              // create a pattern to locate suspect phrases
              $pattern = '/Content-Type:|Bcc:|Cc:/i';
                // function to check for suspect phrases
      function isSuspect($val, $pattern, &$suspect) {
        // if the variable is an array, loop through each element
              // and pass it recursively back to the same function
              if (is_array($val)) {
          foreach ($val as $item) {
                  isSuspect($item, $pattern, $suspect);
                } else {
          // if one of the suspect phrases is found, set Boolean to true
                if (preg_match($pattern, $val)) {
            $suspect = true;
              // check  the $_POST array and any subarrays for suspect content
              isSuspect($_POST, $pattern, $suspect);
              if ($suspect) {
                        $mailSent = false;
                        unset($missing);
              } else {
              //proces the $_POST Variables
              foreach ($_POST as $key => $value) {
                        //assign temporary variable and strip whitespace if not an array
                        $temp = is_array($value) ? $value: trim($value);
                        //if empty and required, add to $missing array
                        if (empty($temp) && in_array($key, $required)) {
                                  array_push($missing, $key);
                        } elseif (in_array($key, $expected)) {
                                  //otherwise, assign to a variable of the same name as $key
                                  ${$key} = $temp;
              // validate the email address
      if (!empty($email)) {
        // regex to identify illegal characters in email address
        $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
              // reject the email address if it doesn't match
        if (!preg_match($checkEmail, $email)) {
          $suspect = true;
          $mailSent = false;
          unset($missing);
              //go ahead ONLY if not suspect and all required fields OK
              if (!$suspect && empty($missing)) {
              // build the message
              $message = "Name: $name\r\n\r\n";
              $message .= "Email: $email\r\n\r\n";
              $message .= "Message: $comments\r\n\r\n";
              //limit line length to 70 characters
              $message = wordwrap($message, 70);
              //Create aditional headers
              $headers = "From: Website Enquiry\r\n";
              $headers .= 'Content-Type: text/plain; charset=utf-8';
              if (!empty($email)) {
              $headers .= "\r\nReply-To: $email";
              //send it
              $mailSent = mail($to, $subject, $message, $headers);
              if ($mailSent) {
                        //$missing is no longer needed if the email is sent, so unset it
                        unset($missing);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <?php
    if ($_POST && $mailSent) { ?>
    <META HTTP-EQUIV="Refresh" CONTENT="5;URL=index.php">
    <?php } ?>
    <title></title>
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <link href="style/style.css" rel="stylesheet" type="text/css" />
    <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-11804201-5']);
      _gaq.push(['_trackPageview']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    </script>
    </head>
    <body<?php if ($_POST && $mailSent){ ?> onLoad="redirect()"<?php } ?>>
    <img src="images/photography/background.jpg" alt="Jack Wilesmith Furniture Design" class="bg" id="bg" />
    <div id="container">
      <div id="Header">
      </div>
      <div id="content">
    <?php
    if ($_POST && isset($missing) && !empty($missing)) {
              ?>
        <p class="warning"><strong>Please complete the missing item(s) indicated.</strong></p><br />
        <?php
    } elseif ($_POST && !$mailSent) {
              ?>
        <p class="warning"><strong>Sorry, there was a problem sending your message, please try again later. </strong></p><br />
              <?php
    } elseif ($_POST && $mailSent) {
              ?>
        <p><strong>Your Message has been sent succesfully - <strong>You will be redirected in 5 seconds</strong></strong></p><br />
    <SCRIPT LANGUAGE="JavaScript"><!--
    function redirect () { setTimeout("go_now()",5000); }
    function go_now ()   { window.location.href = "index.php"; }
    //--></SCRIPT>
        <?php } ?>
        <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
        <p>
          <label for="name">Name:</label><br />
          <input name="name" type="text" class="textInput" id="name"
          <?php if (isset($missing)) {
    echo 'value="' . htmlentities($_POST['name'], ENT_COMPAT, 'UTF-8') . '"';
    ?>
          /> <?php
                if (isset($missing) && in_array('name', $missing)) {?> <span class="warning">Please enter your name</span><?php } ?>
        </p><br />
        <p>
          <label for="email">Email:</label><br />
          <span id="sprytextfield1">
          <input name="email" type="text" class="textInput" id="email"
          <?php if (isset($missing)) {
    echo 'value="' . htmlentities($_POST['email'], ENT_COMPAT, 'UTF-8') . '"';
    ?>
          />
    <span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
          <?php
                if (isset($missing) && in_array('email', $missing)) {?> <span class="warning">Please enter your Email Address</span><?php } ?>
        </p><br />
        <legend></legend>
        <p>
          <label for="comments">Message:</label><br />
          <textarea name="comments" id="comments" cols="45" rows="5"><?php if (isset($missing)) {
                        echo htmlentities($_POST['comments'], ENT_COMPAT, 'UTF-8');
                } ?></textarea><?php
                if (isset($missing) && in_array('comments', $missing)) {?> <span class="warning">Please enter a Message</span><?php } ?>
        </p><br />
        <p class="clearIt">
          <input name="send" type="submit" id="send" value="Send message" />
        </p>
         <input name="email" type="hidden" id="email" value="[email protected]" />
    </form>
    </div>
    </div>
    <script type="text/javascript">
    <!--
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "email", {isRequired:false, hint:"[email protected]"});
    //-->
    </script>
    </body>
    </html>

    Lovely, simple but beautiful!
    Thanks for that.
    T

Maybe you are looking for

  • Searching Issue

    Hi Friends Could you please help me in the following issues?. I have a database two tables called Books and BSearch. When i search a Books Based on a Book category it should take the values related to that Category and store them all in the BSearch t

  • Tracking AR credit memo to AP invoices..

    Hi Guys, can anyone help me in getting invoices generated in AP against credit memo applied in AR. Thanks In Advance Reju

  • Every time I get a voicemail I also get a blank text why would this happen?

    I've noticed that I get unknown blank text every time someone leave me a voicemail.  Has anyone every experienced this?

  • Mail 5.0 mailbox list and message list 1 and 2

    my mail had three columns ; mailbox list, message list and then individual message. the individual message disappeared and i don't see anyway of getting that column back! now i have  to double click a message to see its content whereas before i could

  • Urgent Help with Java!

    How do you open this program on Command Prompt?? okie here i go I saved on dive C: (java) folder and then i put javac GradeReport.java on command pro. but nuttin came up... why is that? I'll really appriciate if anyone can help me out. Thank you! imp