.php file shows code in Chrome

Alex Stack picture Alex Stack · Mar 5, 2013 · Viewed 34.3k times · Source

I have a register page I retrieved off of the following site. I downloaded the source code and extracted the file, finding the login.php. I open it in Adobe Dreamweaver CS3 which loads it and shows no code, but when I click Preview in Chrome, Chrome shows the entire files code, which is shown below. When I click Preview in iExplore, it does the same. Am I doing something wrong or is there something I don't have on my laptop? I have not put the rest of the code for the webpage because I feel it is irevelent as when I cut the php code out and tested it it the page shows. It is just when I insert the PHP code. After the PHP is the normal code that Dreamweaver places in at the start of a new HTML or PHP file.

<?PHP
require_once("./include/membersite_config.php");

if(isset($_POST['submitted']))
{
   if($fgmembersite->Login())
   {
    $fgmembersite->RedirectToURL("login-home.php");
   }
}

   ?>

Answer

niaccurshi picture niaccurshi · Mar 5, 2013

To display PHP on your computer you need to have a local PHP server set up. Without it there is no PHP engine that can interpret and parse your code to make it in to HTML for the browser.

If you haven't got a PHP server installed locally, then you will need to upload your files to a server via FTP, where PHP is installed.