Итак, у меня есть заполненная форма на странице HTML, переданная в скрипт PHP.PHP работает нормально, но у меня возникли проблемы с отображением HTML-кода на странице PHP.Если в теле HTML я делаю <?php echo $message; ?>
, переменная отображается нормально.Но как только я пытаюсь добавить форматирование (особенно div и заголовки), на странице ничего не отображается.Вот что у меня есть.
<?php
session_start();
//declare variables
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
$date = $_POST['date'];
$time = $_POST['time'];
$company = 'Test company';
$_SESSION['name'] = $name;
//strip of invalid chars
$date = str_replace( '/' , '.' , $date);
//fopen
$pathToMe = dirname(__FILE__);
$fileName = $pathToMe . "/days/" . $date;
$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 = 'test@testserver.com';
$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';
}
//confirm email
if ($companyConfirm = $confirm) {
if ($companyConfirm = 'yes') {
$message = "Your appointment has been confirmed. You will recieve a confirmation email shortly";
print "<div id=\"jqt\"><div id=\"home\" class=\"current\"><h1>Scheduler</h1><ul class=\"edit rounded\"><li>" . $message;
}
else {}
} else {
$message = "There was a problem making your appointment. Please call to schedule.";
}
$_SESSION['message'] = $message;
?>
<html>
<body>
<div id="home">
<div class="toolbar">
<h1>Scheduler</h1>
<a class="back" href="#home">Back</a>
</div>
<ul class="edit rounded">
<li><?php echo $message; ?></li>
</ul>
</div>
</div>
</body>
</html>
Будем весьма благодарны за любые мысли о том, как отображать $message
в виде строки с форматированием.