Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2011
    Posts
    212
    Thanks
    10
    Thanked 1 Time in 1 Post

    PHP form not sending email in correct format

    I have a form on my page that sends an email to whoever, it sends the email so far, but it doesnt include any of the variables in it.

    My test site is up at www.trendstudiosorlando.com/test3/index.htm

    As of now, my php page is coded as follows: ( I have blocked out the email, but obviously it can be seen if you check, lol. Is my code wrong?

    <?php
    $errors = '';
    $myemail = '********';//<-----Put Your email address here.
    if(empty($_POST['name']) ||
    empty($_POST['email']) ||
    empty($_POST['message']))
    {
    $errors .= "\n Error: all fields are required";
    }

    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];


    {
    $to = $myemail;
    $email_subject = "You have an appointment request!: $name";
    $email_body = "You have received an appointment request. ".
    " Here are the details:\n Name: $name \n Email: $email \n Phone Number: $phone \n Details \n $comments";

    $headers = "From: $myemail\n";
    $headers .= "Reply-To: $email";

    mail($to,$email_subject,$email_body,$headers);
    //redirect to the 'thank you' page
    header('Location: contact-form-thank-you.html');
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Thank you</title>
    </head>

    <body>
    <!-- This page is displayed only if there is some error -->
    <?php
    echo nl2br($errors);
    ?>


    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,950
    Thanks
    9
    Thanked 724 Times in 718 Posts
    The contact form is missing name attributes for the input fields. In the absence of these there will be no POST data.

  • #3
    Regular Coder
    Join Date
    Mar 2011
    Posts
    212
    Thanks
    10
    Thanked 1 Time in 1 Post
    GOT IT! Thanks!
    Last edited by lmorales; 05-29-2012 at 06:29 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
    •