好吧我确定我在这里做错了什么,但我不能让这些PHP变量显示为内联!PHP Echo没有显示
编辑:这是代码现在看起来像,stil不工作。
<?php
ini_set('display_errors', true); error_reporting(E_ALL);
//declare variables
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
$date = $_POST['date'];
$time = $_POST['time'];
$company = 'Test company';
$dateraw = $date;
$confirmText = "Thank you " . $name . " for booking your appointment with us. We look forward to seeing you at " .$time . " on " . $dateraw . ". You will receive a confirmation email shortly.";
//strip of invalid chars
$date = str_replace('/' , '.' , $date);
//fopen
$pathToMe = dirname(__FILE__);
$fileName = $pathToMe . "/days/" . $date . ".txt";
$fileHandle = fopen($fileName, 'w') or die("Failure.");
fwrite($fileHandle, $name . "\n" . $email . "\n" . $phone . "\n" . $date . "\n" . $time . "\n" . $comments . "\n" . "\n");
fclose($fileHandle);
//email to company
$to = '[email protected]';
$subject = 'Apointment scheduled online';
$body = "An apointment was just scheduled online.\n" . $name . "\n" . $email . "\n" . $phone . "\n" . $date . "\n" . $time . "\n" . $comments . "\n" . "\n" . "Please follow up to confirm.";
if (mail($to, $subject, $body)) {
$companyConfirm = 'yes';
} else {
$companyConfirm = 'no';
}
//client confirm
$to = $email;
$subject = 'Confirming your appointment';
$body = "Hello " . $name . "," . "\n" . "\n" . "You recently booked an appointment with " . $company . " on " . $date . " at " . $time . ".\n" . "\n" . "We will follow up soon to confirm.";
if (mail ($to, $subject, $body)) {
$confirm = 'yes';
} else {
$confirm = 'no';
}
print_r($_POST);
?>
<html>
<head>
</head>
<body>
<div id="jqt">
<div id="home" class="current">
<div class="toolbar">
<h1>Scheduler</h1>
</div>
<ul class="edit rounded">
<li><?php echo $confirmText; ?></li>
</ul>
</div>
</div>
</div>
</body>
</html>
你是否获得了HTML输出而没有PHP变量被echo'd?或者你一无所获?你是在发布到页面(POST和这个输出之间没有重定向?) – HorusKol 2011-05-12 00:23:17
我认为你太过信任你的数据输入。 '$ email = $ _POST ['email']'后面跟着'$ to = $ email'例如。 (SMTP注入。) – 2011-05-12 00:29:50
谢谢@ian,但这纯粹是概念证明,不会公开。 @HorusKol变量正在正常发送(电子邮件确认正在发送,文本文件正在写入正常)。 – 2011-05-12 00:44:42