我仍然是使用PHP的新手,所以我遇到了一个问题,就是当我运行这段代码时,我的浏览器中显示了PHP。 我试着保存文件。 html,这是结果
如果我试图保存它.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 = "IT_Department@8bits.com";
$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>
答案 0 :(得分:2)
编辑:如果您已经安装了WAMP,请运行它,并将项目文件夹放在:c:\wamp\www
内(虽然版本可能有所不同)。
要预览,请在浏览器网址上输入:localhost/yourProjectFolderName
答案 1 :(得分:-1)
问题是您的计算机上没有安装PHP Web服务器。你在Windows上,所以安装Wamp:它是一个多功能的Web服务器,包括Apache2(服务器),PHP(将读取并执行您的PHP代码),MySql和许多其他组件。