SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist mafunk's Avatar
    Join Date
    Apr 2003
    Location
    portland
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Forms not sending Email: Why

    I've made two php forms for my web site:
    http://www.eslessays.com/newsletter.html
    (see php below)

    and
    http://www.eslessays.com/predictor.html
    (see php below)

    I found the script for these forms at http://www.thesitewizard.com/wizards/feedbackform.shtml

    The forms appear to work online (correct page appears when entering data, failing to enter data, etc. . .) Also, I followed direction to a T.

    When I first built the newsletter form it work just fine, and I was receiving my mail. However now neither of the forms are sending me my mail. It was suggested that I upload a test form without making any changes in order to see if it was my host. So I did. However whenever I tried to enter data on form "test.html" I kept getting a page that said "feedback.php not found". I know that the form was there. Also, I wasn't having that problem with the other forms above - they just won't send email.

    So here I sit trying to figure out what the heck is wrong. Any suggestions. . .


    PHP Below:

    newsletter.html (supported by "feedback.php)
    <?
    // ------------- CONFIGURABLE SECTION ------------------------

    // $mailto - set to the email address you want the form
    // sent to, eg
    //$mailto = "youremailaddress@example.com" ;

    $mailto = 'monique@mdcreative.com' ;

    // $subject - set to the Subject line of the email, eg
    //$subject = "Feedback Form" ;

    $subject = "I want to Recieve ESLessays Newsletter and Specials" ;

    // the pages to be displayed, eg
    //$formurl = "http://www.example.com/feedback.html" ;
    //$errorurl = "http://www.example.com/error.html" ;
    //$thankyouurl = "http://www.example.com/thankyou.html" ;

    $formurl = "http://www.eslessays.com/newsletter.html" ;
    $errorurl = "http://www.eslessays.com/newsletter_error.html" ;
    $thankyouurl = "http://www.eslessays.com/newsletter_thnx.html" ;

    // -------------------- END OF CONFIGURABLE SECTION ---------------

    $name = $_POST['name'] ;
    $email = $_POST['email'] ;
    $comments = $_POST['comments'] ;
    $http_referrer = getenv( "HTTP_REFERER" );

    if (!isset($_POST['email'])) {
    header( "Location: $formurl" );
    exit ;
    }
    if (empty($name) || empty($email)) {
    header( "Location: $errorurl" );
    exit ;
    }

    $messageproper =

    "This message was sent from:\n" .
    "$http_referrer\n" .
    "Name:\n" .
    $name .
    "\n------------------------------------------------------------\n" .
    "Email:\n" .
    $email .
    "\n------------------------------------------------------------\n";


    mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>\nReply-To: \"$name\" <$email>\nX-Mailer: chfeedback.php 2.01" );
    header( "Location: $thankyouurl" );
    exit ;

    ?>




    predictor.html (supported by predict.php)

    <?
    // ------------- CONFIGURABLE SECTION ------------------------

    // $mailto - set to the email address you want the form
    // sent to, eg
    //$mailto = "youremailaddress@example.com" ;

    $mailto = 'monique@mdcreative.com' ;

    // $subject - set to the Subject line of the email, eg
    //$subject = "predict" ;

    $subject = "What are my chances for admission?" ;

    // the pages to be displayed, eg
    //$formurl = "http://www.example.com/feedback.html" ;
    //$errorurl = "http://www.example.com/error.html" ;
    //$thankyouurl = "http://www.example.com/thankyou.html" ;

    $formurl = "http://www.eslessays.com/predictor.html" ;
    $errorurl = "http://www.eslessays.com/predictor_error.html" ;
    $thankyouurl = "http://www.eslessays.com/predictor_thnx.html" ;

    // -------------------- END OF CONFIGURABLE SECTION ---------------

    $name = $_POST['name'] ;
    $email = $_POST['email'] ;
    $rank = $_POST['class ranking'] ;
    $size = $_POST['class size'] ;
    $gpa = $_POST ['gpa'] ;
    $satmath= $_POST ['satmath'] ;
    $satverbal= $_POST ['satverbal'] ;
    $satII= $_POST ['satII'] ;
    $ap= $_POST ['ap'] ;
    $parents= $_POST ['parents'] ;
    $extra= $_POST ['extra'] ;
    $http_referrer = getenv( "HTTP_REFERER" );

    if (!isset($_POST['email'])) {
    header( "Location: $formurl" );
    exit ;
    }
    if (empty($name) || empty($email)) {
    header( "Location: $errorurl" );
    exit ;
    }

    $messageproper =

    "This message was sent from:\n" .
    "$http_referrer\n" .
    "Name:\n" .
    $name .
    "\n------------------------------------------------------------\n" .
    "Email:\n" .
    $email .
    "\n------------------------------------------------------------\n" .
    "Class Ranking:\n" .
    $rank .
    "\n------------------------------------------------------------\n" .
    "Class Size:\n" .
    $size .
    "\n------------------------------------------------------------\n" .
    "GPA:\n" .
    $gpa .
    "\n------------------------------------------------------------\n" .
    "Math score on SAT:\n" .
    $satmath .
    "\n------------------------------------------------------------\n" .
    "Verbal score on SAT:\n" .
    $satverbal .
    "\n------------------------------------------------------------\n" .
    "SAT II scores:\n" .
    $satII .
    "\n------------------------------------------------------------\n" .
    "Do you have two or more AP scores:\n" .
    $ap .
    "\n------------------------------------------------------------\n" .
    "Have either of your parents graduated from college:\n" .
    $parents .
    "\n------------------------------------------------------------\n" .
    "What is your extracurricular ranking on a scale from one to ten?:\n" .
    $extra .
    "\n------------------------------------------------------------\n" ;


    mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>\nReply-To: \"$name\" <$email>\nX-Mailer: chpredict.php 2.01" );
    header( "Location: $thankyouurl" );
    exit ;

    ?>
    MaFunk

  2. #2
    SitePoint Addict seanmayhew's Avatar
    Join Date
    Aug 2002
    Posts
    209
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Were you able to get this to work because this seems to work to me. Make sure your email is correct or that something is not wrong with your email account.

  3. #3
    SitePoint Evangelist mafunk's Avatar
    Join Date
    Apr 2003
    Location
    portland
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Sean,

    When you say that you got them to work what do you mean?

    Did you upload the above script to your host? Or did you use the form wizard to make a form script that works? Or did you successfully send an email using my forms?

    This morning I received a couple of emails that I had sent out and one where the user put in "kb_armstrong@shaw.ca" as the email address. So it seems like the script is working, but that I only get the email once in awhile. . . .

    What do I do to fix this. . . . . Do you know?

    Thanks
    MaFunk
    MaFunk

  4. #4
    SitePoint Addict seanmayhew's Avatar
    Join Date
    Aug 2002
    Posts
    209
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I used your script but here is the form I used
    http://www.heliocreative.com/newsletterform.htm

    It worked for me everytime without fail. Im going to go ahead and change the email address on the above form so that it goes to your account. Let me know if it works. I would recommend trying another email account such as a hotmail account. For the script to be submitted to. To see if it works.


Bookmarks

Posting Permissions

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