www.webdeveloper.com
Results 1 to 4 of 4

Thread: Hello, i need help with a faily simple contact form/php script (error somewhere)

  1. #1
    Join Date
    Sep 2012
    Posts
    3

    Question Hello, i need help with a faily simple contact form/php script (error somewhere)

    Hello im new here and found this site on google. I was hoping someone here could help me find problem. I created a form with html...i also created the php script to make the form work....but its not working for some reason. Im sure it will be something small....like a space or period where it shouldnt be.

    Here's the html:

    HTML Code:
     <table width="85%" border="1" cellpadding="5">
      <tr>
        <td><form action="contactformprocess.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
          <p>
            <label><span class="contacttext">First Name: *</span>
    <input type="text" name="firstname" id="firstname" />
            </label>
          </p>
          <p>
            <label><span class="contacttext">Last Name: *</span>
    <input type="text" name="lastname" id="lastname" />
            </label>
          </p>
          <p>
            <label><span class="contacttext"> Phone # where you can be reached: </span>
              <input type="text" name="cellphone" id="cellphone" />
            </label>
          </p>
          <p>
            <label><span class="contacttext">Email:*</span>
    <input type="text" name="email" id="email" />
            </label>
          </p>
          <span class="contacttext">How do you prefer to be contacted?</span>
    <table width="200">
      <tr>
        <td><label>
          <input type="checkbox" name="prefercontactemail" value="email" id="HowDoYouPreferToBeContacted_0" />
          E-mail</label></td>
        </tr>
      <tr>
        <td><label>
          <input type="checkbox" name="prefercontactphone" value="phone" id="HowDoYouPreferToBeContacted_1" />
          Phone</label></td>
        </tr>
    </table>
          <p>
          <p>
            <label><span class="contacttext">Where Did You Originally Hear Of Us? *</span>
    <input type="text" name="reference" id="reference" />
            </label>
          <p>
            <label><span class="contacttext">Comments and Concerns: *</span><br />
              <textarea name="comments" id="comments" cols="50" rows="5"></textarea>
            </label>
          </p>
          <p>
            <label>
              <input name="submit" type="submit" id="submit" onclick="MM_validateForm('firstname','','R','lastname','','R','RisNum','cellphone','','NisNum','email','','RisEmail','reference','','R','comments','','R');return document.MM_returnValue" value="Submit" />
            </label>
            <label>
              <input type="reset" name="reset" id="reset" value="Reset" />
            </label>
          </p>
          <p>
            <input name="recipient" type="hidden" id="recipient" value="contactus@ape-xnutrition.com" />
            <input name="redirect" type="hidden" id="redirect" value="thankyou.html" />
          </p>
          
        </form></td>
      </tr>
    </table>
    here's the php script:

    PHP Code:
    <?php

    /* Subject and Email varibales */

        
    $emailSubject 'Contact Ape-X Nutrition';
        
    $webMaster 'contactus@ape-xnutrition.com';
        
    /* Gathering Data Variables */

        
    $firstnameField $_POST['firstname'];
        
    $lastnameField $_POST['lastname'];
        
    $cellphoneField $_POST['cellphone'];
        
    $emailField $_POST['email'];
        
    $prefercontactemailField $_POST['prefercontactemail'];
        
    $prefercontactphoneField $_POST['prefercontactphone'];
        
    $referenceField $_POST['reference'];
        
    $commentsField $_POST['comments'];
        
        
    $body = <<<EOD
    <br><hr><br>
    First Name: 
    $firstname <br>
    Last Name: 
    $lastname <br>
    Phone: 
    $cellphone <br>
    Email: 
    $email <br>
    Prefered to be contacted: 
    $prefercontactemail <br>
    Prefered to be contacted: 
    $prefercontactphone <br>
    Who referred you: 
    $reference <br>
    Comments: 
    $comments <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
    <html>
    <head>
    <title>Ape-x Nutrition</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    body {
        background-color: #f1f1f1;
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 12px;
        font-style: normal;
        line-height: normal;
        font-weight: normal;
        color: #666666;
        text-decoration: none;
    }
    -->
    </style>
    </head>

    <div>
      <div align="left">Thank you for your interest! Your email will be addressed shortly!</div>
    </div>
    </body>
    </html>
    EOD;
    echo 
    "$theResults";

    ?>

  2. #2
    Join Date
    Mar 2009
    Posts
    452
    put error_reporting(E_ALL); on 2nd line, then post what error you get

  3. #3
    Join Date
    Sep 2012
    Posts
    3
    Quote Originally Posted by ZABI View Post
    put error_reporting(E_ALL); on 2nd line, then post what error you get

    let me start off by saying ty for helping me...it's much appreciated.

    I have done what you asked and this is what pops up:

    Notice: Undefined index: prefercontactphone in /home/content/48/9893048/html/contactformprocess.php on line 15

    Notice: Undefined variable: firstname in /home/content/48/9893048/html/contactformprocess.php on line 22

    Notice: Undefined variable: lastname in /home/content/48/9893048/html/contactformprocess.php on line 23

    Notice: Undefined variable: cellphone in /home/content/48/9893048/html/contactformprocess.php on line 24

    Notice: Undefined variable: email in /home/content/48/9893048/html/contactformprocess.php on line 25

    Notice: Undefined variable: prefercontactemail in /home/content/48/9893048/html/contactformprocess.php on line 26

    Notice: Undefined variable: prefercontactphone in /home/content/48/9893048/html/contactformprocess.php on line 27

    Notice: Undefined variable: reference in /home/content/48/9893048/html/contactformprocess.php on line 28

    Notice: Undefined variable: comments in /home/content/48/9893048/html/contactformprocess.php on line 28

    Notice: Undefined variable: email in /home/content/48/9893048/html/contactformprocess.php on line 31
    Thank you for your interest! Your email will be addressed shortly!

  4. #4
    Join Date
    Sep 2012
    Posts
    3
    i removed the ''Field'' from from the variables and it now works. ZABI...ty. I was able to find the errors from your ''error_reporting(E_ALL);''

    it is much appreciated brother. Thank you

    This can be marked as resolved.

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