我创建了一个简单的表单,将输入的值通过电子邮件发送到指定的电子邮件。
另外,我想在确认页面上显示输入/选择的值。我使用以下代码:
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>';
它的显示方式如下:
感谢您注册
您已注册以下课程9:10到10:00 am:“$ email9_11”
上午10:10至11:00:“$ email10_11”
11:10至12:00:“$ email11_12”
12:10至1:00:“$ email12_1”我们期待着与您相见 2010年10月31日
以下是变量:
$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'];
我很感激帮助让它正确显示。
谢谢!
答案 0 :(得分:3)
您正在为echo
使用单引号,在这种情况下,不会展开变量。改为使用双引号:(当然,在文本中使用双引号)
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>";
答案 1 :(得分:2)
如果要输出内联变量值而不是变量名,请用双引号括起回声。
$var = "foo";
echo '$var'; //Outputs $var
echo "$var"; //Outputs foo
您还需要在内容中转义\"
双引号。
希望这有帮助。