The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP Form Question(s)

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 61 total)
  • Author
  • #33444

    Please let me know if this is not appropriate for CSS-Tricks.

    I have 2 PHP forms on my website, the results for each form are to be e-mailed. Upon submit, on both forms, I get the message that the requests have been e-mailed successfully, and actually get the email. The trouble is, the emails are empty.

    I guess it is safe to assume that the form.php files are located correctly on the server(?) They aren’t in any special place,but residing in my root folder and identified by the server as being “application/x-httpd-php” files.

    I haven’t configured any “mail-handler” application. The server supports cgimail and has it installed I thought I had better stay with the php script because it seems to “halfway” work. Where do I go from here to resolve my dilemma?


    Something is wrong with your _POST _GET areas


    Geez! I’m such a noob. Let me check it out. Briefly looking at it, I think I know where the problems lie. Thanks Steven.


    Here is what I’m looking at, no _GET anywhere, I expanded on what I needed in my form after watching a video tutorial…… The following is from the smaller files that captures input from a simple email form.

    /* Subject & Email Variables for Quote Form*/

    $emailSubject = ' Request for Information' ;
    $webMaster = ' [email protected]' ;

    /* Gathering Data Variables for Quote Form*/

    $email = $_POST [ 'email' ] ;
    $myQuestions = $_POST [ 'myQuestions' ] ;

    /* Email Structure of Form Information from Quote Form */

    $body = <<

    Email Address: $email

    My Questions : $myQuestions


    $headers = "From : $emailrn ";
    $headers .= "Content-type: text/htmlrn " ;
    $success = mail ( $webMaster, $emailSubject, $body, $headers ) ;

    /* Results rendered as HTML */

    $theResults = <<
    ..........followed by HTML for my site's header, body, footer, etc

    echo "$theResults";


    This is the string I am questioning:

    $success = mail ( $webMaster, $emailSubject, $body, $headers ) ;

    I’m using “mail” because it is what was used in the tutorial, and have been in search of clearing this up for a couple of hours .. to no avail. I’m assuming, unless there is something glaring that I should be embarrassed about, this ‘mail’ string might be the culprit?


    tried it without “$success =” ?


    Thanks for your reply, and willingness to help me out.

    I commented out the line in question, no e-mail is send at all. As stevendeeds suggested, am I omitting _GET somewhere? I admit I am lost here, but am keeping a stiff upper lip about it. :-) I’ve looked at other examples, and have seen no reference to _GET (?)


    I use a form myself that works perfectly but the code is a bit different from yours. Seems to work pretty well. Used it on a few occasions. The way I do it is have the form on a page say contact.php and have the form send to sendemail.php. This is the script inside sendemail.php. Obviously you can modify it and include the rest of your site design around it.

    $name = $_POST;
    $email = $_POST;
    $message = $_POST;

    if(!$email == "" && (!strstr($email,"@") || !strstr($email,".")))
    echo "

    Please enter a valid email address in the format: [email protected]

    $badinput = "

    Your query has not been sumbitted.

    echo $badinput;
    die ("Press back on your browser and try again.");

    if(empty($name) || empty($email) || empty($message )) {
    echo "

    You did not enter information in all the fields.

    die ("

    Press back on your browser and try again.


    $subject = "whatever you want the subject";
    $message = "Date: $todayis n
    From: $name (Email: $email) n
    Message: $message n
    $from = "From: $emailrn";

    mail("[email protected]", $subject, $message, $from);

    Thank you, your request has been submitted successfully.


    Thanks AWKM, I appreciate your tenacity in trying to help me solve this problem. Let me check it out. I’m not concerned with the differences in code at this point, if it works for you, I’m willing to give it a try.

    In my searching for a solution I have run across many people with the same problem as I have. The video tutorial was a popular tutvids tutorial, that seemingly drew a large crowd. I’m actually surprised, his videos are generally spot on.

    I’ll be back to report! Thanks again!


    I don’t know, not having too much luck with the coding you provided above AWKM. I fail to get a returned e-mail, I will toy around with it further. Naturally, I had to modify it for the values I have in my form, etc.

    I’m thinking, I’m not married to php in getting something suitable to bring form data into an e-mail. I may have ta abandon php, and look for alternatives. Cgi-email I believe can do the same thing, minus the php scripting. I thought, since I am also working on a WP blog for my site, the continued exposure to php would aid me in learning more about php.

    If anyone has $.02 they would like to share, I’m open. If I need to, I can share my actual html forms ……………. I find it difficult to believe that with all this talent on the forums, someone hasn’t stepped forward with a “tried and true work-around. ;-)

    This saga will continue ….


    I would start by commenting out the part that sends the email and just echoing out all of your variables from the form.

    Heres a very stripped down version of an email sent in PHP.

    Hope this helps to get you on the right track.

    // Variables from form. Im not really using these anywhere in the email below. I just set them as an example.
    $email = $_POST;
    $firstname = $_POST;
    $lastname = $_POST;
    $password = sha1($_POST);
    $city = $_POST;
    $state = $_POST;
    // subject
    $subject = 'Thanks for signing up!';

    // HTML message
    $message = '

    ' . $_POST . ' signed up for RYFO.

    ' . $_POST . ',

    Thanks for signing up.

    Your login credentials are

    Username: ' . $_POST . '
    Password: ' . $_POST . '

    We hope to see you around the community.


    // To send HTML mail, the Content-type header must be set
    $headers = 'MIME-Version: 1.0' . "rn";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";

    // Additional headers
    $headers .= 'To: ' . $_POST . ' <' . $_POST . '>' . "rn";
    $headers .= 'From: RYFO ' . "rn";

    // Mail it
    mail($to, $subject, $message, $headers);


    I’d like to see your HTML just to see the naming. It may be that simple. I’ve looked over code for hours before and found that I’d named something wrong.


    Here’s the HTML, sorry I’ve been late in getting back to see all this activity, I’ve been scouring the web all morning, been up since 5AM:

    Ah, how do I post HTML without having the coding stripped away?


    Hmmm. That didnt post the HTML. Surround your code with


Viewing 15 posts - 1 through 15 (of 61 total)
  • The forum ‘Back End’ is closed to new topics and replies.