开发者

How do I display PHP form values on the confirmation page?

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!


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>";


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜