i am trying to write a simple login page in client side - html , and server side - php . The following code runs in my virtual machine-kali linux . When i run login.html file i get the code in php(the commands and all i wrote) with the login format(the format is ok) but the php code is appearing and doesn't run. i've tried EVERYTHING! please can you tell me what is the problem?
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>