SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Atlanta
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Email Form: I feel like such an idiot!

    OK, here's the deal. Although I've done a basic PHP email-sending form before, I'm definitely a novice! Based on my past form success, I promised a client that I would build out two forms by tomorrow morning. I have been slaving away all evening and have nothing that will work. I need a quick and dirty solution that will capture the form data and send it to an email address. Simple enough, right? Apparently novice isn't a good enough word. I'm a PHP dunce!!!

    Can anyone help to point me in the right direction? I have tried formmail with no success. My old script looked something like the following and isn't doing anything. I click submit and NOTHING happens. Any help would be greatly appreciated!

    <?php

    $mail_to = "tim@timothygray.com";
    $mail_subject = "Website Form Submittal";
    $mail_header = "The following user has registered.";
    $error_page = "http://www.wrightcomputers.net/contact/index.htm";
    $success_page = "http://www.wrightcomputers.net/contact/index.htm";

    if($_POST['email'] != '') {
    header("Location: $error_page");
    } else {
    $from = $_POST['email'];
    $subject = $mail_subject;
    $to = mail_to;
    $body = \n $mail_header \n \n $from;
    mail($mail_to, $mail_subject, $body);
    header("Location: $success_page");
    }

    ?>

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $body = \n $mail_header \n \n $from;
    Not sure if that was a typo, but it should be:
    $body = $mail_header."\n\n".$from;

    Failing that put error_reporting(E_ALL); at the top of the script in case there's problems you are not seeing. Also check the mail log (if you have access) and see if it's getting that far.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Atlanta
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by markl999
    Not sure if that was a typo, but it should be:
    $body = $mail_header."\n\n".$from;

    Failing that put error_reporting(E_ALL); at the top of the script in case there's problems you are not seeing. Also check the mail log (if you have access) and see if it's getting that far.
    Thanks - I actually found a few errors in the script. I've got it working now though...


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
  •