Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Jan 2009
    Posts
    2
    Member #
    18070
    I've helping a friend populate a template he bought. I've done pretty well so far, but I'm having a bugger of a time getting the contact form to work properly. So far I have it half working. I get an email at the specified address, but it does not include a name, address or phone number. The message field does show up in the body of the email though. Where have I gone wrong?

    Thanks

    Here's the html
    Code:
      <div class="line"></div>
                                                    <form id="form" action="" enctype="multipart/form-data" name="form">
                                                        <table class="form">
                                                            <tr>
                                                                <td width="170">
                                                                    Your name:
                                                                    <div class="h_f"><input type="text"></div>
                                                                    E-mail address:
                                                                    <div class="h_f"><input type="text"></div>
                                                                    Phone:
                                                                    <div class="h_f"><input type="text"></div>                                                            </td>
                                                                <td>
                                                                    Your message:
                                                                    <textarea cols="2" rows="2"></textarea><br>
                                                                    <a href="#"  onclick="document.getElementById('form').reset()" style="margin:0 11px 0 70px;">Clear</a><a href="#" onClick="document.getElementById('form').submit()">Submit</a>                                                            </td>
    and here's the php that goes with it
    Code:
    <?
    $subject="from ".$_GET['Name'];
    $headers= "From: ".$_GET['Email']."\n";
     $headers.='Content-type: text/html; charset=iso-8859-1';
    mail("*****@hotmail.com", $subject,  "
    <html>
    <head>
     <title>Contact letter</title>
    </head>
    <body>
    
    <br>
      ".$_GET['Phone']."
    <br>
      ".$_GET['Message']."
    </body>
    </html>" , $headers);
    echo ("Your message was successfully sent!");
    ?>
    <script>
        resizeTo(300, 300)
        //window.close()
    </script>

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Hi. Below are some pointers based on the code you provided.

    1. Your form does not have an action attribute (currently it reads action="")
    2. Your form has no method set. get is the fallback but you should specify which method (get or post)
    3. You have enctype="multipart/form-data but based on your code it does not look like you are offering an upload feature.
    4. I am not sure how the message works and the others do not because they are all missing a name attribute.

    You have code like
    PHP Code:
    $subject="from ".$_GET['Name']; 
    however no field in your form has a name of Name (perhaps call it fullname instead to make the code easier to follow). You will need to add similar for email and phone (such as name="emailAddress" and name="phoneNumber" respectively).

    5. You have a link which clears the form however forms already have a way of doing this - see below
    HTML Code:
    <input type="reset" name="reset" value="Clear" />
    Same goes for submit...
    HTML Code:
    <input type="submit" name="submit" value="E-mail me" />
    I think the biggest problem you have is not naming the form fields.

    Good luck.

  4. #3
    Junior Member
    Join Date
    Jan 2009
    Posts
    2
    Member #
    18070
    It worked! Thanks for the help the form now works.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:36 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com