好吧我確定我在這裏做錯了什麼,但我不能讓這些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