1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Why is my contact form not working?

Discussion in 'HTML & Website Design' started by JasMate, Feb 2, 2007.

  1. #1
    My site diet-book.org has a contact for here: http://diet-book.org/contact.php The problem is when the form is submitted I only get a blank email with no subject or body. Can anyone tell me how to fix this? I think the form uses a coniguration.php file and a contact.php file.

    Thanks for the assistance :)
    ..
     
    JasMate, Feb 2, 2007 IP
  2. DatR

    DatR Peon

    Messages:
    210
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    the form goes to a file called "submit.php"... you would have to show the code in this file for anyone to be able to fix it for you
     
    DatR, Feb 2, 2007 IP
  3. JasMate

    JasMate Active Member

    Messages:
    2,592
    Likes Received:
    74
    Best Answers:
    0
    Trophy Points:
    90
    #3
    Thanks here is the code, looks good to me but can you see something out of place?
    <?php
    
    // headers for the email listed below
    
    $headers .= "From: $name <$email>\n";  // your email client will show the person's email address like normal
    $headers .= "Content-Type: text/plain; charset=iso-8859-1\n"; // sets the mime type
    $recipient = "me@me.com (yes I have changed this)";       // enter YOUR email address here
    $subject = "Email from your Ebook Website"; // this is the subject of the email
    
    $msg = wordwrap( $msg, 1024 );
    
    mail($recipient, $subject, stripslashes($msg), $headers); // the mail() function sends the message to you
    
    //Once the data is entered, redirect the user to give them visual confirmation
       header("location: thanks.php");
    ?>
    PHP:
     
    JasMate, Feb 2, 2007 IP
  4. programmersbank

    programmersbank Peon

    Messages:
    184
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    can you provide form html code? have you received email without use wordwrap function?
     
    programmersbank, Feb 2, 2007 IP
  5. JasMate

    JasMate Active Member

    Messages:
    2,592
    Likes Received:
    74
    Best Answers:
    0
    Trophy Points:
    90
    #5
    Below is the form code. I don' t know if I got the email from wordwrap or not, I just get blank emails, that do (come to think of it) have the subject intact "Email from your Ebook Website" but the emails are blank (no body text).

    <html><head><meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
    <?php include('configuration.php'); ?>
    <title><?php title() ?>Contact Us</title>
    <?php metatags() ?>
    <?php css() ?></head>
    <?php bodytag() ?>
    <?php topheader() ?>
    <table border=0 cellspacing=0 cellpadding=0 width=100% class=back2>
    <tr valign=top><td width=100%><span style="font-size:12">
    <center><span style="font-size:24"><font color=#00008B><b>contact us</b></font></span></center>
    <center><img border="0" src="/images/slimming2.jpg" width=200 height=150 alt="Buy slimming ebooks"></center><p>
    <form name="form" method="post" action="submit.php">
      <table width="450" border="0" cellpadding="2" cellspacing="2" summary="">
        <tr> 
          <td width="100%" valign="top" align="left"><span style="font-size:12"><b>Your Name: </b><br>     
            <input type="text" name="name" size="30" maxlength="60" />
          </td>
        </tr>
        <tr> 
          <td width="100%" valign="top" align="left"><span style="font-size:12"><b>Your Email Address:</b><br>
               <input type="text" name="email" size="30" maxlength="60" />
          </td>
        </tr>
        <tr> 
             <td width="250" valign="top" align="left"> <span style="font-size:12"><b>Your Message:</b><br>
                <textarea name="msg" cols="50" rows="10"></textarea>
          </td>
        </tr>
        <tr> 
             <td width="250" valign="top" align="left"> 
                   <input type="submit" name="Send" value="Send Email" />
          </td>
        </tr>
      </table>
      </form>
    </td></tr></table>
    <?php footer() ?>
    </body></html>
    PHP:
     
    JasMate, Feb 2, 2007 IP
  6. DatR

    DatR Peon

    Messages:
    210
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #6
    try putting this for the wordwrap line

    
    $msg = wordwrap( $_POST["msg"], 1024 );
    
    Code (markup):
    and you might also want to check that the email it says its being sent from is the email you type in your form as well.. so you may want to change this line as well to this code:

    
    $headers .= "From: $_POST["name"] <$_POST["email"]>\n";
    
    Code (markup):
     
    DatR, Feb 2, 2007 IP
  7. JasMate

    JasMate Active Member

    Messages:
    2,592
    Likes Received:
    74
    Best Answers:
    0
    Trophy Points:
    90
    #7
    Didn't like that, this is what I got when trying to submit the form after making the changes:
     
    JasMate, Feb 2, 2007 IP
  8. DatR

    DatR Peon

    Messages:
    210
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #8
    oops... it should be like this...

    
    $headers .= "From: " . $_POST["name"] . " <" . $_POST["email"] . ">\n";
    
    Code (markup):
     
    DatR, Feb 2, 2007 IP
    JasMate likes this.
  9. JasMate

    JasMate Active Member

    Messages:
    2,592
    Likes Received:
    74
    Best Answers:
    0
    Trophy Points:
    90
    #9
    Your a champ! works great, thanks so much rep comming your way - :p

    ...
     
    JasMate, Feb 2, 2007 IP
  10. DatR

    DatR Peon

    Messages:
    210
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #10
    no problem... glad I could help
     
    DatR, Feb 2, 2007 IP