Form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
beanboy3001
Forum Newbie
Posts: 10
Joined: Mon May 11, 2009 10:49 am

Form

Post by beanboy3001 »

My boss is wanting me to do a form and I know just enough php to be dangerous since I'm just starting to learn.
I have a html form and a php processor in separate files.
When I fill out the form online and hit submit it redirects me, pulls up the thank you screen, and sends the email just like it should.
However it will not put the information from the form into the email. So I end up with a blank email with nothing but a subject.

Any thoughts?
The html can be seen on http://www.razorbacksrealestate.com/con ... mpage.html

Here is the php

Code: Select all

<?php
ini_set("SMTP","maila26.webcontrolcenter.com");
ini_set("smtp_port","8889");
ini_set("sendmail_from","razorback@razorbacksrealestate.com");
 
/* Subject and Email Variables */
 
    $emailSubject = 'Big Test';
    $webMaster = 'jonathan@bdglr.com';
    
/* Gathering Data Variables */
 
    $emailField = $_POST['email'];
    $nameField = $_POST['name'];
    $phoneField = $_POST['phone'];
    $budgetField = $_POST['budget'];
    $travelersField = $_POST['travelers'];
    $commentsField = $_POST['comments'];
    $newsletterField = $_POST['newsletter'];
    
    $body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Phone Number: $phone <br>
Budget: $budget <br>
Number of Travelers: $travelers <br>
Comments: $comments <br>
Newsletter: $newsletter <br>
EOD;
 
    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body, $headers);
    
/* Results Rendered as HTML */
 
    $theResults = <<<EOD
<html>
<head>
<title>JakesWorks - travel made easy-Homepage</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
    background-color: #f1f1f1;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-style: normal;
    line-height: normal;
    font-weight: normal;
    color: #666666;
    text-decoration: none;
}
-->
</style>
</head>
 
<div>
  <div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
 
?>
any thoughts
Last edited by Benjamin on Tue May 12, 2009 12:30 pm, edited 1 time in total.
Reason: Changed code type from text to php.
Griven
Forum Contributor
Posts: 165
Joined: Sat May 09, 2009 8:23 pm

Re: Form

Post by Griven »

You're creating a variable called $emailField, and assigning it a value. Then, in the email, you're calling up a completely different variable called $email. This won't work.

Use the variable names that you created and assigned the POST values.

Code: Select all

# /* Gathering Data Variables */
 
     $emailField = $_POST['email'];
     $nameField = $_POST['name'];
     $phoneField = $_POST['phone'];
     $budgetField = $_POST['budget'];
     $travelersField = $_POST['travelers'];
     $commentsField = $_POST['comments'];
     $newsletterField = $_POST['newsletter'];
    
     $body = <<<EOD
 <br><hr><br>
 Email: $emailField <br>
 Name: $nameField <br>
 Phone Number: $phoneField <br>
 Budget: $budgetField <br>
 Number of Travelers: $travelersField <br>
 Comments: $commentsField <br>
 Newsletter: $newsletterField <br>
Last edited by Benjamin on Tue May 12, 2009 2:16 pm, edited 1 time in total.
Reason: Changed code type from text to php.
divito
Forum Commoner
Posts: 89
Joined: Sun Feb 22, 2009 7:29 am

Re: Form

Post by divito »

Griven beat me to it.
Griven
Forum Contributor
Posts: 165
Joined: Sat May 09, 2009 8:23 pm

Re: Form

Post by Griven »

divito wrote:Griven beat me to it.
:D
beanboy3001
Forum Newbie
Posts: 10
Joined: Mon May 11, 2009 10:49 am

Re: Form

Post by beanboy3001 »

you guys are brilliant! Thanks
Post Reply