我還在使用PHP,所以我有一個問題,當我運行這段代碼,我的瀏覽器中的PHP顯示。 我試着保存文件。 HTML,這是結果爲什麼php代碼在我的網站頁面顯示?
,如果我試圖挽救它.PHP,這是結果
,這裏是我的代碼
誰能幫助我 ?!
代碼:
<?php
include_once ("php_includes/check_login_status.php");
//If user is already logged in, header it away
if ($member_ok == true)
{
header ("location: Member.php?u=".$_SESSION["Username"]);
exit();
}
?>
<?php
//AJAX calls this part to be executed
if (isset($_POST["e"]))
{
$e = mysqli_real_escape_string($db_conx, $_POST['e']);
$sql = "SELECT MmeberID, Username FROM Member WHERE Email='$e' AND activated='1' LIMIT 1";
$query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($query);
if ($numrows > 0) // The member exists
{
while($row = mysqli_fetch_array($query, MYSQLI_ASSOC))
{
$id = $row["id"];
$u = $row["username"];
}
$emailcut = substr($e, 0, 4); //Cut the first 4 character of their mail
$randNum = rand(10000,99999); // generate 5 digits random number
$tempPass = "$emailcut$randNum"; //concatinate these two var to make the new random pass
$hashTempPass = md5($tempPass); //hash this new random password
$sql = "UPDATE Member SET temp_pass='$hashTempPass' WHERE Username='$u' LIMIT 1"; //Update the member table with the new password
$query = mysqli_query($db_conx, $sql);
$to = "$e";
$from = "[email protected]";
$headers ="From: $from\n";
$subject ="yoursite Temporary Password";
$msg = '<h2>Hello '.$u.'</h2>
<p> Somebody recently asked to reset your Facebook password. Didnt request this change? If you didnt request a new password.</p>
<p>We can generated a temporary password for you to log in with, then once logged in you can change your password to anything you like.</p>
<p>After you click the link below your password to login will be:<br /><b>'.$tempPass.'</b></p>
<p><a href="http://www.yoursite.com/forgot_pass.php?u='.$u.'&p='.$hashTempPass.'">Click here now to apply the temporary password shown below to your account</a></p>
<p>If you do not click the link in this email, no changes will be made to your account. In order to set your login password to the temporary password you must click the link above.</p>';
if(mail($to,$subject,$msg,$headers))
{
echo "success";
exit();
}
else
{
echo "email_send_failed";
exit();
}
}
else
{
echo "no_exist";
}
exit();
}
?>
<!DOCTYPE html>
<html>
<header id = "PageHeader">
<script type="text/javascript" src = "Index.js"> </script>
<meta charset="utf-8">
<!-- The website title -->
<TITLE> 8 BITES </TITLE>
<!-- Include the CSS file with this HTML file-->
<link rel="icon" type="iamge/x-icon" href="C:/Users/hp1/Desktop/Website/Pictures/Logo.jpg">
<link rel="stylesheet" type="text/css" href="Style.css">
<img id = "HeaderLogo" src = "C:/Users/hp1/Desktop/Website/Pictures/T_Logo.jpg" alt="Logo" style="width:46px; height:46px;">
<h2 id = "HeaderQuote"> 8BITS </h2>
</header>
<body id ="ForgetPasswordPageBody">
<?php include_once("template_pageTop.php"); ?>
<h1> Generate temporary log in password </h1>
<p> Note: This password will last only for 24 hours. In orde to obtain a new valid password please contact us! </p>
<form id = "ForgotPassForm">
<div id = "Step1"> Step 1: Enter your Email! </div>
<input id = "Email" type="Email" onfocus="_('status').innerHTML ='';" maxlength="100">
<br/>
<button id = "ForgotPass" onclick="ForgotPass()"> Generate </button>
<p id = "status"> </p>
</form>
<script>
function ForgotPass()
{
var email = ("Email").value;
if (email == " ")
{
_("status").innerHTML = "Type your Email address!";
}
else
{
_("ForgotPass").style.display = "none";
_("status").innerHTML = 'Please wait...';
var ajax = ajaxObj ("POST", "forgot_pass.php");
ajax.onreadystatechange = function()
{
if (ajaxRetrun (ajax) == true)
{
var response = ajax.responseText;
if (response == "success")
{
_("ForgotPassForm").innerHTML = '<h3> Step 2. Check your Email inbox please </h3>';
}
else if (response == "no_exist")
{
_("status").innerHTML = "This is Email is not registered!";
}
else if (response =="email_send_falied")
{
_("status").innerHTML = "Mail falid to be sent!";
}
else
{
_("status").innerHTML = "An unknow error occured!";
}
}
}
ajax.send ("e=" +e);
}
}
</script>
<?php include_once("template_pageBottom.php"); ?>
</body>
<footer id = "PageFooter">
<div id = "Info">
<ul id = "InfoLinks">
<li> <a href ="AboutPage.html" target="_blank"> About </a> </li>
<li> <a href ="HelpPage.html" target="_blank"> Help </a> </li>
<li> <a href ="TermsPage.html" target="_blank"> Terms </a> </li>
<li> <a href ="PrivacyPage.html" target="_blank"> Privacy </a> </li>
<li> <a href ="CookiesPage.html" target="_blank" > Cookies </a> </li>
<li> <a href ="AddsInfoPage.html" target="_blank"> Adds Info </a> </li>
<li> @2017 8Bits </li>
</ul>
</div>
<div id = "Media">
<ul id = "MediaLinks">
<li> <a href ="https://www.facebook.com/MIU8BITS/" target="_blank"> <img src = "C:/Users/hp1/Desktop/Website/Pictures/Facebook.jpg" alt="Facebook" style="width:40px;height:40px;"> </a> </li>
<li> <a href ="#" target="_blank"> <img src = "C:/Users/hp1/Desktop/Website/Pictures/YouTube.jpg" alt="YouTube" style="width:40px;height:40px;"> </a> </li>
<li> <a href ="#" target="_blank"> <img src = "C:/Users/hp1/Desktop/Website/Pictures/Instagram.jpg" alt="Instagram" style="width:40px;height:40px;"> </a> </li>
<li> <a href ="#" target="_blank"> <img src = "C:/Users/hp1/Desktop/Website/Pictures/Twitter.jpg" alt="Twitter" style="width:40px;height:40px;"> </a> </li>
</ul>
</div>
</footer>
</html>
你需要一個服務器端語言PHP的本地主機服務器。在Google上搜索WAMP或XAMPP或AMPPS。 – paolobasso
你的服務器是什麼?你的PHP引擎沒有運行。 –
默認情況下,使用php提供的文件必須具有'.php'文件擴展名。也有助於擁有一臺可以運行這些文件的服務器,而且您不能像在純文本文件中那樣在瀏覽器中雙擊它們。 – cteski