+ Reply to Thread
Results 1 to 10 of 10

Thread: PHP Contact Form

  1. #1
    jakeselectronics is offline x10Hosting Member jakeselectronics is an unknown quantity at this point
    Join Date
    Mar 2009
    Posts
    38

    PHP Contact Form

    I had a working Contact form and now it has parcially stopped working.

    I have the form on my site, and what it would do is send me an email, as well as the person who sent it. Like an auto reply confirmation email to them.

    I have been sitting here all day trying to figure out whats wrong and I still am not sure.

    I have norrowed it down though.
    When i take the '$from' bit out of this: $send = mail($to, $subject, $body, $from);
    It works.

    But the email ends up in my junk folder. without a from address. Which is annoying because i cant just hit reply.
    and when its included ( '$from' ), i dont get an email at all.

    here's the whole .php code:
    Can anyone see anything obvioulsy wrong.
    PHP Code:
    <?php
    if (isset($_POST['submit'])){
     
     
    $name $_POST['name'];
     
    $email $_POST['email'];
     
    $subjectabout $_POST['subject']; 
     
    $mailinglist $_POST['list'];
     
    $message $_POST['message'];
     
     
    $to "jephpform@hotmail.com";
     
    $subject "JE - Result From Web Form";
     
    $from "From: $name <$email>"
     
     
    $body "Name: $name\nE-Mail: $email\nSubject: $subjectabout\nAdd to Mailing list: $mailinglist\nMessage:\n\n       $message";
     
     
    $autoreplymessage "Thanks $name for contacting me.\nI will get back to you as soon as possible.\n\n\nThe following information was sent:\n$body";
     
    $autoreplysubject "Thank you for contacting Jake"
     
    $autoreplyheader "From: NoReply - Jake's Electronics <noreply@jakeselectronics.com>"
     
    if(
    $name == ''
    {
    header"Location: http://jakeselectronics.x10hosting.com/con-incomplete.php" );}  
    else { 
    if(
    $email == ''
    {
    header"Location: http://jakeselectronics.x10hosting.com/con-incomplete.php" );}  
    else {
    if(
    $message == ''
    {
    header"Location: http://jakeselectronics.x10hosting.com/con-incomplete.php" );}  
    else { 
    $send mail($to$subject$body$from);           // This sends an email to me
    $send2 mail($email$autoreplysubject$autoreplymessage$autoreplyheader);  // This sends an email to them
    if($send
    {
    header"Location: http://jakeselectronics.x10hosting.com/con-thanks.php" );} 
    else 
    {
    header"Location: http://jakeselectronics.x10hosting.com/con-error.php" );} 
    }
    }
    }
    }
    ?>
    And here's my webpage for the contact form..
    http://jakeselectronics.x10hosting.com/contact.php

  2. #2
    vishal's Avatar
    vishal is offline -::-X10 Guru-::- vishal has a brilliant futurevishal has a brilliant future
    Join Date
    Nov 2009
    Location
    INDIA
    Posts
    5,254

    Re: PHP Contact Form

    Pls include validation , i will check ur code and post the reply as soon as possible.
    Regards ~ Vishal
    Giving Reputation (at bottom of my post ) is the best way to encourage the person who helped you on forums.

  3. #3
    jakeselectronics is offline x10Hosting Member jakeselectronics is an unknown quantity at this point
    Join Date
    Mar 2009
    Posts
    38

    Re: PHP Contact Form

    Someone just sent an email using the current contact form

    heres a picture of what i got.
    1,2 and 3 are what I just received.
    picture 4 is the way it used to work. (ignore the different receive address)

    The different between them is that the persons email address doesn't show up anymore.
    This is why it ends up in the junk folder, plus i cant press 'reply'.

    notice in picture 4, the name and the email of the person using the form would come through.



    is there anything wrong with this:?
    PHP Code:
    $from "From: $name <$email>"
    Because when i add this: nothing comes through at all.
    PHP Code:
    mail($to$subject$body$from); 
    This is how it is for the email i received in the picture above:
    PHP Code:
    mail($to$subject$body); 

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: PHP Contact Form

    In the past, users have reported that PHP mail has stopped going out if the "From" header was from a third party...hotmail, gmail, etc, even though it worked for awhile.

    By setting the "From" header to an address from your website, the mail started going out again. I do not remember anybody saying posting back later saying it stopped.

    Maybe the mail server is set up to monitor outgoing to make sure that accounts are not used for "phishing" and stop sending emails that have questionable (ie not attached to the account) "From" headers. Admin has never commented on this.
    Nothing is always absolutely so.

  5. #5
    jakeselectronics is offline x10Hosting Member jakeselectronics is an unknown quantity at this point
    Join Date
    Mar 2009
    Posts
    38

    Re: PHP Contact Form

    So there's not too much wrong with the code.
    Well I guess it worked before...

    So if i was to change servers/hosts, it may possibly start working properly again?

  6. #6
    vishal's Avatar
    vishal is offline -::-X10 Guru-::- vishal has a brilliant futurevishal has a brilliant future
    Join Date
    Nov 2009
    Location
    INDIA
    Posts
    5,254

    Re: PHP Contact Form

    I checked it and it was working.. If you want i will mail you another contact form.PM me ur mail id
    Regards ~ Vishal
    Giving Reputation (at bottom of my post ) is the best way to encourage the person who helped you on forums.

  7. #7
    marley17's Avatar
    marley17 is offline x10Hosting Member marley17 is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    58

    Re: PHP Contact Form

    for alternatives,,, you could try a free service of jotform... the site is http://www.jotform.com

    its a web based form creator, i do have three accounts on there because they only allow 100 messages per month on a free account.so when the one expires i use the other account.. hehe. i found it useful since in reality people use the contact form not too often ... whats great is .. less bandwidth usage, more secure... and you are confident that messages are send right away..
    Last edited by marley17; 01-13-2010 at 10:18 PM.

  8. #8
    xgreenberetx is offline x10Hosting Member xgreenberetx is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    57

    Re: PHP Contact Form

    Code:
        $to = $email;
        $subject = 'Your Registration';
        $message = '<html><body>
        Please follow these instructions to verify your registration:<BR>
    Instructions bla bla' ;
        $headers .= "From:$email \r\n";
        $headers .= "Reply-To: <"$email">\r\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    
    mail($to, $subject, $message, $headers)
    Try using the header option instead, and see if that works out.

  9. #9
    jakeselectronics is offline x10Hosting Member jakeselectronics is an unknown quantity at this point
    Join Date
    Mar 2009
    Posts
    38

    Re: PHP Contact Form

    Thanks for your help xgreenberetx

    but i got an error with this line
    PHP Code:
       $headers .= "Reply-To: <"$email">\r\n"
    this is what the error said:
    Parse error: syntax error, unexpected T_VARIABLE in /home/jakesele/public_html/sendmail.php on line 15
    Edit:
    Problem solved!

    There's nothing wrong with the coding.

    I switched Webhosts and walla! it works perfectly!

    Thanks for all your help though everyone.

    Now, who wants all my credits?

    haha just kidding :D
    Last edited by jakeselectronics; 01-14-2010 at 12:58 AM. Reason: Automerged Doublepost

  10. #10
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: PHP Contact Form

    Quote Originally Posted by jakeselectronics View Post
    but i got an error with this line
    PHP Code:
       $headers .= "Reply-To: <"$email">\r\n"
    The line is missing string concatenation operators or has extra double-quotes (depending on how you want to view it).
    PHP Code:
       $headers .= "Reply-To: <" $email">\r\n";
    // OR
       
    $headers .= "Reply-To: <$email>\r\n"
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. [PHP] How to create a simple contact form
    By nightscream in forum Tutorials
    Replies: 6
    Last Post: 01-23-2011, 11:37 AM
  2. PHP Contact form
    By itradio in forum Programming Help
    Replies: 3
    Last Post: 05-10-2009, 11:13 PM
  3. How to: Contact form with PHP
    By tttony in forum Scripts & 3rd Party Apps
    Replies: 0
    Last Post: 12-29-2008, 06:29 PM
  4. Javascript form to PHP
    By driveflexfuel in forum Scripts & 3rd Party Apps
    Replies: 3
    Last Post: 10-28-2008, 11:15 PM
  5. Addon Domain PHP Form Error
    By rockee in forum Free Hosting
    Replies: 2
    Last Post: 04-02-2008, 06:53 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
x10hosting free hosting for the masses
dedicated servers