【发布时间】:2017-05-23 19:14:53
【问题描述】:
我正在尝试使用 xampp 在 localhost 上加载我的起始页 (php)。只要我将文件保存为 html 文档(另存为 start.html),它就会显示出来,但是一旦我将其保存为 php 文件(为了执行 $_SESSION['id'] 它就无法加载文件(基本上是无限加载过程,但没有出现错误。这是我的代码。非常感谢任何帮助。谢谢
<?php
session_start();?>
<html>
<head>
<title>
I am a login project
</title>
<meta charset="utf-8">
<link rel="stylesheet" href='style.css' type="text/css">
</head>
<body>
<form method="post" action="login.php">
<input type="text" placeholder="uid" name="Username">
<input type="password" placeholder="Password" name="pwd">
<button type="submit" name="submit">LOGIN</button>
</form>
<br>
<?php
if(isset($_SESSION['id'])){
echo $_SESSION['id'];
}
?>
<form method="post" action="signup.php">
<input type="text" placeholder="first" name="first">
<input type="text" placeholder="last" name="last">
<input type="text" placeholder="uid" name="Username">
<input type="password" placeholder="Password" name="pwd">
<button type="submit" name="submit">SIGN_UP</button>
</form>
<br>
<form method="post" action="logout.php">
<button type="submit" name='logout'>LOGOUT</button>
</form>
</body>
</html>
【问题讨论】:
-
尝试空白 index.php 页面并运行
<?php phpinfo();以确保 php 配置正确。您在正确的目录中吧? -
<?php之前真的有空格吗?试试error_reporting(E_ALL); ini_set('display_errors', '1'); -
应该配置正确。当我用 start.html 文件调用我的 signup.php 时,它可以工作并执行 signup.php。