Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Posts
    70
    Plugin Contributions
    0

    red flag Contact Form PHP help

    Hi I am working on a contact form…
    Not sure why its not working this is my first PHP form…

    everything looks right. can some one take a look please.

    thanks
    Heres the HTML code
    HTML Code:
    <form name="contactform" method="post" action="send_form_email.php">
    <table width="450px">
    <tr>
     <td valign="top">
      <label for="Business_name">Business Name*</label>
     </td>
     <td valign="top">
      <input  type="text" name="Business_name" maxlength="50" size="30">
     </td>
    </tr>
    <tr>
     <td valign="top"">
      <label for="Contact_name">Contact Name*</label>
     </td>
     <td valign="top">
      <input  type="text" name="Contact_name" maxlength="50" size="30">
     </td>
    </tr>
    <tr>
     <td valign="top"">
      <label for="Address">Address*</label>
     </td>
     <td valign="top">
      <input  type="text" name="Address" maxlength="50" size="30">
     </td>
    </tr>
    <tr>
     <td valign="top"">
      <label for="City">City*</label>
     </td>
     <td valign="top">
      <input  type="text" name="City" maxlength="50" size="30">
     </td>
    </tr>
    <tr>
     <td valign="top"">
      <label for="State">State*</label>
     </td>
     <td valign="top">
      <input  type="text" name="State" maxlength="50" size="30">
     </td>
    </tr>
    <tr>
     <td valign="top"">
      <label for="Zip">Zip*</label>
     </td>
     <td valign="top">
      <input  type="text" name="Zip" maxlength="50" size="30">
     </td>
    </tr>
    <tr>
     <td valign="top">
      <label for="email">Email Address*</label>
     </td>
     <td valign="top">
      <input  type="text" name="email" maxlength="80" size="30">
     </td>
    </tr>
    <tr>
     <td valign="top">
      <label for="telephone">Telephone Number*</label>
     </td>
     <td valign="top">
      <input  type="text" name="telephone" maxlength="30" size="30">
     </td>
    </tr>
    <tr>
     <td valign="top"">
      <label for="Fax">Fax*</label>
     </td>
     <td valign="top">
      <input  type="text" name="Fax" maxlength="50" size="30">
     </td>
    </tr>
    <tr>
     <td valign="top"">
      <label for="Website">Website*</label>
     </td>
     <td valign="top">
      <input  type="text" name="Website" maxlength="50" size="30">
     </td>
    </tr>
    <tr>
     <td valign="top">
      <label for="Locations">How Many Locations do you operate and where are they located?*</label>
     </td>
     <td valign="top">
      <textarea  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
     </td>
    </tr>
    <tr>
     <td valign="top">
      <label for="Brands">What other brands do you carry?*</label>
     </td>
     <td valign="top">
      <textarea  name="Brands" maxlength="1000" cols="25" rows="6"></textarea>
     </td>
    </tr>
    <tr>
     <td valign="top">
      <label for="Tell">Please tell us more about your business and why your interested in becoming a our dealer.*</label>
     </td>
     <td valign="top">
      <textarea  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
     </td>
    </tr>
    <tr>
     <td colspan="2" style="text-align:center">
      <input type="submit" value="Submit">  
     </td>
    </tr>
    </table>
    </form>
    Heres the PHP code
    PHP Code:
    <?php
    if(isset($_POST['email'])) {
         
        
    // EDIT THE 2 LINES BELOW AS REQUIRED
        
    $email_to "[email protected]";
        
    $email_subject "DEALER INQUIRY";
         
         
        function 
    died($error) {
            
    // your error code can go here
            
    echo "We are very sorry, but there were error(s) found with the form you submitted. ";
            echo 
    "These errors appear below.<br /><br />";
            echo 
    $error."<br /><br />";
            echo 
    "Please go back and fix these errors.<br /><br />";
            die();
        }
         
        
    // validation expected data exists
        
    if(!isset($_POST['Business_name']) ||
            !isset(
    $_POST['Contact_name']) ||
            !isset(
    $_POST['Address']) ||
            !isset(
    $_POST['City']) ||
            !isset(
    $_POST['State']) ||
            !isset(
    $_POST['Zip']) ||
            !isset(
    $_POST['email']) ||
            !isset(
    $_POST['telephone']) ||
            !isset(
    $_POST['Fax']) ||
            !isset(
    $_POST['Locations']) ||
            !isset(
    $_POST['Brands']) ||
            !isset(
    $_POST['Tell'])) {
            
    died('We are sorry, but there appears to be a problem with the form you submitted.');       
        }
         
        
    $Business_name $_POST['Business_name']; // required
        
    $Contact_name $_POST['Contact_name']; // required
        
    $Address $_POST['Address']; // required
        
    $City $_POST['City']; // required
        
    $State $_POST['State']; // required
        
    $Zip $_POST['Zip']; // required
        
    $email $_POST['email']; // required
        
    $telephone $_POST['telephone']; // required
        
    $Fax $_POST['Fax']; // required
        
    $Locations $_POST['Locations']; // required
        
    $Brands $_POST['Brands']; // required
        
    $Tell $_POST['Tell']; // required

         
        
    $error_message "";
        
    $email_exp '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
      if(!
    preg_match($email_exp,$email_from)) {
        
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
      }
        
    $string_exp "/^[A-Za-z .'-]+$/";
      if(!
    preg_match($string_exp,$Business_name)) {
        
    $error_message .= 'The Business Name you entered does not appear to be valid.<br />';
      }
      if(!
    preg_match($string_exp,$Contact_name)) {
        
    $error_message .= 'The Contact Name you entered does not appear to be valid.<br />';
      }
      if(
    strlen($Tell) < 2) {
        
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
      }
      if(
    strlen($error_message) > 0) {
        
    died($error_message);
      }
        
    $email_message "Form details below.\n\n";
         
        function 
    clean_string($string) {
          
    $bad = array("content-type","bcc:","to:","cc:","href");
          return 
    str_replace($bad,"",$string);
        }
         
        
    $email_message .= "Business Name: ".clean_string($Business_name)."\n";
        
    $email_message .= "Contact Name: ".clean_string($Contact_name)."\n";
        
    $email_message .= "Address: ".clean_string($Address)."\n";
        
    $email_message .= "City: ".clean_string($City)."\n";
        
    $email_message .= "State: ".clean_string($State)."\n";
        
    $email_message .= "Zip: ".clean_string($Zip)."\n";
        
    $email_message .= "Email: ".clean_string($email_from)."\n";
        
    $email_message .= "Telephone: ".clean_string($Telephone)."\n";
        
    $email_message .= "Fax: ".clean_string($Fax)."\n";
        
    $email_message .= "Locations: ".clean_string($Locations)."\n";
        
    $email_message .= "Brands: ".clean_string($Brands)."\n";
        
    $email_message .= "Tell: ".clean_string($Tell)."\n";

         
    // create email headers
    $headers 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' phpversion();
    @
    mail($email_to$email_subject$email_message$headers);  
    ?>
     
    <!-- include your own success html here -->
     
    Thank you for contacting us. We will be in touch with you very soon.
    We will now redirect you to our Home Page.
     <meta http-equiv="Refresh" content="4; url=http://www.mysite.Biz">
    <?php
    }
    ?>

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Contact Form PHP help

    At a glance (helped by syntax highlighting in your posted code) you have an extra " in several instances of this line:

    <td valign="top"">

 

 

Similar Threads

  1. Simple CSS/PHP AntiSpam solution for a contact form
    By dlg_ie in forum All Other Contributions/Addons
    Replies: 130
    Last Post: 24 Jan 2017, 05:04 PM
  2. Help!Footer was gone when I use fast secure contact form php script version
    By newbie456 in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 2 Mar 2012, 10:15 AM
  3. Custom Contact Form Help
    By notfarnow in forum General Questions
    Replies: 0
    Last Post: 26 Apr 2010, 04:49 AM
  4. Move Contact Us form above define_contact_us.php
    By swiss1939 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 19 Nov 2008, 02:39 PM
  5. Please Help Contact Us Form Focus
    By cs_jono in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 7 Nov 2007, 08:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg