tags:

views:

35

answers:

2

I have created a simple form that emails the entered values to a designated email.

In addition I would like to display the entered / selected values on the confirmation page. I am using the following code:

echo '<h2>Thank you for Registering</h2>
        <h3>You have registered for the following classes</h3>
        <p>9:10 to 10:00am: "$email9_11" <br />
             10:10 to 11:00am: "$email10_11"<br />
             11:10 to 12:00:  "$email11_12"<br />
             12:10 to 1:00: "$email12_1"</p>
        <p>We look forward to seeing you October 31, 2010</p>';

This is how it displays:

Thank you for Registering
You have registered for the following classes

9:10 to 10:00am: "$email9_11"
10:10 to 11:00am: "$email10_11"
11:10 to 12:00: "$email11_12"
12:10 to 1:00: "$email12_1"

We look forward to seeing you October 31, 2010

Here are the variables:

$emailFromName = $_POST['name'];
$emailFrom = $_POST['email'];
$emailFromPhone = $_POST['phone'];
$email9_11 = $_POST['9-10'];
$email10_11 = $_POST['10-11'];
$email11_12 = $_POST['11-12'];
$email12_1 = $_POST['12-1'];

I would appreciate help getting this to display properly.

Thanks!

+2  A: 

You are using single quotes for your echo, in which case variables will not be expanded. Use double quotes instead: (and of course escape the double quotes inside your text)

echo "<h2>Thank you for Registering</h2>
        <h3>You have registered for the following classes</h3>
        <p>9:10 to 10:00am: \"$email9_11\" <br />
             10:10 to 11:00am: \"$email10_11\"<br />
             11:10 to 12:00:  \"$email11_12\"<br />
             12:10 to 1:00: \"$email12_1\"</p>
        <p>We look forward to seeing you October 31, 2010</p>";
casablanca
Perfect. Thanks.
fmz
+1  A: 

Wrap your echo in double-quotes if you want to output variable values inline instead of variable names.

$var = "foo";
echo '$var'; //Outputs $var
echo "$var"; //Outputs foo

You'll also need to escape \" the double-quotes inside the content.

Hope this helps.

Rookz
Good principles here. The example above was clearer for a php newb. Thank you.
fmz