Php mail pulling form data from previous page
- by Mark
So I have a form being filled out on one php like so:
<p>
<label for="first_name">First Name: </label>
<input type="text" size="30" name="first_name" id="first_name"/>
</p>
<p>
<label for="last_name"> Last Name:</label>
<input type="text" size="30" name="last_name" id="last_name"/>
</p>
<p>
<label for="address_street">Street:</label>
<input type="text" size="30" name="address_street" id="address_street"/>
</p>
<p>
<label for="address_city">City:</label>
<input type="text" size="30" name="address_city" id="address_city"/>
</p>
<p>
<label for="address_state">State/Province:</label>
<input type="text" size="30" name="address_state" id="address_state"/>
</p>
<p>
<label for="email">Your e-mail: </label>
<input type="text" size="30" name="email" id="email"/>
</p>
<p>
<label for="phone">Your phone number: </label>
<input type="text" size="30" name="phone" id="phone"/>
</p>
This is on one php page. From here, it goes to another php which part of it contains script to send a html email to recipient.
Problem is, I cannot seem to get it to pull the variables even though I thought I declared them correctly and mixed them into the html correctly.
<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$to = "[email protected], [email protected]";
$subject = "HTML email for ALPS";
$message .= '
<html>
<body>
<div style="display: inline-block; width: 28%; float: left;">
<img src="http://englishintheusa.com/images/alps-logo.jpg" alt="ALPS Language School" />
</div>
<div style="display: inline-block; width: 68%; float: right;">
<p style="color: #4F81BD; font-size: 20px; text-decoration: underline;">Thanks You For Your Inquiry!</p>
</div>
<div style="padding-left: 20px; color: #666666; font-size: 16.8px; clear: both;">
<p>Dear $first_name $last_name ,</p>
</br >
<p>Thank you for the following inquiry:</p>
</br >
</br >
</br >
</br >
<p>****Comment goes here****</p>
</br >
</br >
<p>We will contact you within 2 business days. Our office is open Monday-Friday, 8:30 AM - 5:00 PM Pacific Standard Time.</p>
</br >
<p>Thank you for your interest!</p>
</br >
</br >
<p>Best Regards,</p>
</br >
</br >
<p>ALPS Language School</p>
</br >
</br >
<p>430 Broadway East</p>
<p>Seattle WA 98102</p>
<p>Phone: 206.720.6363</p>
<p>Fax: 206. 720.1806</p>
<p>Email: [email protected]</p>
</div>
</body>
</html>';
// Always set content-type when sending HTML email
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
mail($to,$subject,$message,$headers);
?>
So you see where I am trying to get first_name and last_name. Well it doesn't come out correctly.
Can someone help here?