【发布时间】:2011-11-04 13:10:21
【问题描述】:
我目前正在尝试在 JQuery 页脚中使用 print,但它不起作用。相反,什么也没有出现。在早期的 php 页面中,我使用...将其存储到会话中。
session_start();
$_SESSION['username'] = $_POST['username'];
我的html页面中的代码如下...
<?php session.start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Food For Thought</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" />
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
</head>
<body>
<div data-role="page" id="page1">
<div data-role="header" id = "hdrMain" name = "hdrMain" data-nobackbtn = "true">
<h1>Food for Thought</h1>
</div><!-- /header -->
<div data-role="content" align ="center">
<a href="game.html" rel="external" data-role="button">Play</a>
<a href="profile.html" data-role="button">Profile</a>
<a href="index.html" data-role="button">Logout</a>
</div><!-- /content -->
<div data-role="footer">
<p>Logged in as: <?php print $_SESSION["username"]; ?> </p>
</div>
</div>
</body>
</html>
感谢您的帮助。
编辑:问题是我试图运行 php 代码的文件以 .html 而不是 .php 结尾。感谢所有试图提供帮助的人。
【问题讨论】:
-
这个页脚与 jquery 有什么关系?
-
如果保存为 .html 的页面比 php 标记不起作用,并且您的会话开始语句在 html 页面中是错误的,它应该是 session_start();
-
我改了,还是不行。页脚只是使页脚(jquery mobile 中的黑条)说“登录为:用户名”,除了用户名没有显示。
标签: php html session jquery-mobile