-2

I am still new with using PHP, so i am having a problem which is when i run this code, the PHP show in my browser. I tried saving the file. html and this is the result

File.html

and if I tried to save it .php, this is the result

File.php

and here is my code

Can anyone help me ?!

Code:

<?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>
TheGrimBoo
  • 199
  • 1
  • 4
  • 14

2 Answers2

2

EDIT: If you have WAMP installed already, run it, and place your project folder inside of: c:\wamp\www (could vary upon version though).

To preview it, type on your browser URL: localhost/yourProjectFolderName

Syden
  • 8,425
  • 5
  • 26
  • 45
-1

The problem is that you have no PHP web server installed on your computer. You're on Windows, so install Wamp : it's an all-in-one web server that includes Apache2 (the server), PHP (who will read and execute your php code), MySql ans lots of others components.

BDeliers
  • 74
  • 1
  • 12