PHP 和 jQTouch

发布于 2024-11-06 11:47:55 字数 2568 浏览 2 评论 0原文

我在 HTML 页面上填写了一个表单并传递给 PHP 脚本。 PHP 运行良好,但在显示 PHP 页面上的 HTML 时遇到一些问题。如果在 HTML 正文中我执行 变量显示正常。但是,一旦我尝试添加格式(特别是 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 = '[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';
}

//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 显示与格式内联的想法将不胜感激。

So I've got a fill out form on an HTML page passed to a PHP script. The PHP runs fine but I'm having some trouble getting the HTML on the PHP page to display. If in the body of the HTML I do <?php echo $message; ?> the variable displays fine. But as soon as I try to add formatting (divs and headers specifically) nothing displays on the page. Here's what I've got.

<?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 = '[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';
}

//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>

Any thoughts as how to get $message displayed inline with formatting would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦里人 2024-11-13 11:47:55

您在其他浏览器中尝试过吗?

看来您在 之前多了一个

如果是这种情况,即使它没有显示在您的浏览器窗口上,如果你查看 html 源代码,你应该会看到它。

编辑:您还有 print 语句,该语句留下 aa li 和许多打开的 div 标签

Have you tried in other browsers?

It seems that you have an extra </div> before </body>

If that is the case, even if it does not show up on your browser window, you should see it if you look at the html source.

EDIT: and you also have that print statement which leaves a a li and a lot of div tags opened

沉溺在你眼里的海 2024-11-13 11:47:55

您使用的是 jQT 的哪个版本?当前版本要求在任何内容之前有一个带有 jqt ID 的 div。

<html>
<head>
</head>
<body>
  <div id="jqt">
  ...
  </div>
</body>
</html>

看看官方 GitHub 存储库中的演示 -> https://github.com/senchalabs/jQTouch

What revision of jQT are you using? The current revision requires a div with an jqt ID before any content.

<html>
<head>
</head>
<body>
  <div id="jqt">
  ...
  </div>
</body>
</html>

Take a look at the demos in the official GitHub repo -> https://github.com/senchalabs/jQTouch

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文