我正在尝试在客户端编写一个简单的登录页面--html和服务器端 - php。以下代码在我的虚拟机-kali linux中运行。 当我运行login.html文件时,我得到了php中的代码(命令和我写的所有内容)和登录格式(格式没问题)但是php代码出现了并且没有运行。我已经尝试过一切了!请问你能告诉我这是什么问题吗?
的login.php
session_start();
if(isset($_POST['Submit'])){
$logins = array("nombre" => "1234","name1" => "pass1");
//prompt from user
$Username = isset($_POST['Username']) ? $_POST['Username'] : "error";
$Password = isset($_POST['Password']) ? $_POST['Password'] : "error";
if (isset($logins[$Username]) && $logins[$Username] == $Password){
$_SESSION['UserData']['Username']=$logins[$Username];
header("location:index.php");
exit;
} else {
$msg="<span style='color:red'>Invalid Login Details</span>";
}
}
?>
<b>
<!doctype html>
<html>
<head>
</head>
<body>
<br>
<form action="" method="post" name="Login_Form">
<table width="400" border="0" align="center" cellpadding="5" cellspacing="1" class="Table">
<?php if(isset($msg)){?>
<tr>
<td colspan="2" align="center" valign="top"><?php echo $msg;?></td>
</tr>
<?php } ?>
<tr>
<td align="right" valign="top">Username</td>
<td><input name="Username" type="text" class="Input"></td>
</tr>
<tr>
<td align="right">Password</td>
<td><input name="Password" type="password" class="Input"></td>
</tr>
<tr>
<td><input name="Submit" type="submit" value="Login" class="Button3"></td>
</tr>
</table>
</form>
</body>
</html>
</b>