www.webdeveloper.com
Results 1 to 6 of 6

Thread: Form not sending

  1. #1
    Join Date
    Sep 2010
    Posts
    3

    Form not sending

    Hello, This is the first form I have built, I am using a .php script to process the data. I have followed the directions and can't seem to find any bugs myself. The form says the message has been sent but it doesnt show up in the email.

    here is the html
    Code:
    <!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>Product Inquiry</title>
    </head>
    
    <body>
    <form action="FormToEmail.php" method="post" name="Product Inquiry">
    <input type="hidden" name="redirect" value="index.html" />
    
    <label for="name">Name</label> <input name="Name" type="text" /><br />
    
    <label for="company">Company</label> <input name="Company" type="text" /><br />
    
    <label>Phone Number</label> <input name="Phone" type="text" /><br />
    
    <label for="email">Email </label><input type="text" name="email" />
    <br /><br />
    
    <label for="interested">I am interested in:</label>
    <p>
            <label>
                    <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_0" />
                    Pop Up Displays</label>
            <br />
            <label>
                    <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_1" />
                    Retractables</label>
            <br />
            <label>
                    <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_2" />
                    X-Banner Stands</label>
            <br />
            <label>
                    <input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_3" />
                    Promotion Tables</label>
            <br />
    
    </p>
    
    <label for="inquiry">Questions/Comments</label><br />
    <textarea name="inquiry" cols="40" rows="5"></textarea><br /><br />
    <input name="submit" type="submit" value="submit" />
    </form>
    
    
    </body>
    </html>
    here is the .php
    Code:
    <?php
    
    error_reporting(E_ALL ^ E_NOTICE);
    
    
    
    
    $my_email = "internationalinkjet@earthlink.net";
    
    
    
    $from_email = "";
    
    
    $continue = "/";
    
    
    $errors = array();
    
    // Remove $_COOKIE elements from $_REQUEST.
    
    if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
    
    // Validate email field.
    
    if(isset($_REQUEST['email']) && !empty($_REQUEST['email']))
    {
    
    $_REQUEST['email'] = trim($_REQUEST['email']);
    
    if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ") || stristr($_REQUEST['email'],"\\") || stristr($_REQUEST['email'],":")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}}
    
    }
    
    // Check referrer is from same site.
    
    if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}
    
    // Check for a blank form.
    
    function recursive_array_check_blank($element_value)
    {
    
    global $set;
    
    if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
    else
    {
    
    foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}
    
    }
    
    }
    
    recursive_array_check_blank($_REQUEST);
    
    if(!$set){$errors[] = "You cannot send a blank form";}
    
    unset($set);
    
    // Display any errors and exit if errors exist.
    
    if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;}
    
    if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");}
    
    // Build message.
    
    function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}
    
    $message = build_message($_REQUEST);
    
    $message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."Thank you for using FormToEmail from http://FormToEmail.com";
    
    $message = stripslashes($message);
    
    $subject = "FormToEmail Comments";
    
    $subject = stripslashes($subject);
    
    if($from_email)
    {
    
    $headers = "From: " . $from_email;
    $headers .= PHP_EOL;
    $headers .= "Reply-To: " . $_REQUEST['email'];
    
    }
    else
    {
    
    $from_name = "";
    
    if(isset($_REQUEST['name']) && !empty($_REQUEST['name'])){$from_name = stripslashes($_REQUEST['name']);}
    
    $headers = "From: {$from_name} <{$_REQUEST['email']}>";
    
    }
    
    mail($my_email,$subject,$message,$headers);
    
    ?>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    
    <head>
    <title>International Inkjet Supply</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body bgcolor="#ffffff" text="#000000">
    
    <div>
    <center>
    <b>Thank you <?php if(isset($_REQUEST['name'])){print stripslashes($_REQUEST['name']);} ?></b>
    <br>Your message has been sent
    <p><a href="<?php print $continue; ?>">Click here to continue</a></p>
    
    </center>
    </div>
    
    </body>
    </html>
    Thank you very much for any help

  2. #2
    Join Date
    Oct 2005
    Location
    Cambridgeshire, UK
    Posts
    191
    Hi jtb. There are a couple of reasons why you're script might not send the email.

    Please see this useful thread here to name just a few:

    http://www.phpbuilder.com/board/show...php?t=10335752

    On a side note, are you running your script locally (ie. on your own machine) or on a remote server?

    BIOSTALL

  3. #3
    Join Date
    Sep 2010
    Posts
    3
    Thanks for the help biostall. As of now I uploaded the script to a godaddy server.

  4. #4
    Join Date
    May 2005
    Location
    Gold Coast (MS)
    Posts
    2,219
    Your current hosting package MUST allow SMTP ( http://en.wikipedia.org/wiki/Simple_...nsfer_Protocol ) to work. Otherwise, no email can be sent.

    PHP: Sending Email Tutorial (Text/HTML/Attachments): http://www.webcheatsheet.com/php/sen...attachment.php

    Use any of the below sites to make the workable form you need:

    For making forms:

    These are really good online form makers. Just follow the instructions for making it and uploading file(s).

    Contact Form Generator: http://www.tele-pro.co.uk/scripts/contact_form/
    WYSIWYG Form Maker: http://www.jotform.com/?gclid=CNKhqe...FRQhnAod6laUqA
    http://www.thesitewizard.com/wizards/feedbackform.shtml
    Ajax - Creating an HTML Form: http://www.tizag.com/ajaxTutorial/ajaxform.php
    http://www.phpform.org/

    http://www.thepcmanwebsite.com/form_mail.shtml
    http://emailmeform.com/
    http://www.freecontactform.com/
    http://www.reconn.us/content/view/12/34/ (Download - Contact Us Script)
    http://formsmarts.com/

    http://apptools.com/phptools/forms/forms1.php
    Form Service: http://www.mycontactform.com/
    Online Free Tool, PHP Contact Form Code Generator: http://www.htmlbasix.com/contactform.shtml
    PHP Mailer Script Step by Step: http://www.htmlgoodies.com/beyond/ph...le.php/3855686
    PHP Sending E-mails: http://www.w3schools.com/PHP/php_mail.asp

    Freebie: Good looking Fluid Contact Form: http://www.flashuser.net/flash-compo...tact-form.html

    Not receiving form result emails?

    This problem is caused by one of two things:

    1) Either your hosting provider does not allow sendmail to work with PHP, or 2) your PHP is configured to not use sendmail. In either case, contact your hosting provider and ask them to configure sendmail to work with your PHP.

    Note: When sending mail, the mail must contain a Form header. This can be set with the additional_headers parameter, or a default can be set in php.ini.
    Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.

    Note: If messages are not received, try using a LF (\n) only. Some poor quality Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with &#187; RFC 2822.

  5. #5
    Join Date
    Sep 2010
    Posts
    3
    hey major, thanks a bunch, i got the form working now.

  6. #6
    Join Date
    May 2005
    Location
    Gold Coast (MS)
    Posts
    2,219
    You're welcome. Would let us know what you had to do to correct the problem just in case others are following this thread? Thanks. Glad you got it working.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles