【问题标题】:PHP and jQTouchPHP 和 jQTouch
【发布时间】:2011-05-11 00:54:08
【问题描述】:

所以我在传递给 PHP 脚本的 HTML 页面上填写了表单。 PHP 运行良好,但在显示 PHP 页面上的 HTML 时遇到了一些问题。如果在 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 与格式内联显示的想法将不胜感激。

【问题讨论】:

  • 看不到任何会让它失败的东西,但我注意到的一件事是你有$companyConfirm = $confirm 这可能不是你想要的(赋值与相等)。
  • 感谢您指出这一点,已修复。

标签: php html forms session-variables jqtouch


【解决方案1】:

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

看来&lt;/body&gt;前面多了一个&lt;/div&gt;

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

编辑:你也有 print 声明,它留下一个 li 和很多 div 标签打开

【讨论】:

    【解决方案2】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多