Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.php file shows code in Chrome [closed]

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");
   }
}

   ?>
like image 767
Alex Stack Avatar asked Mar 05 '13 00:03

Alex Stack


3 Answers

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.

like image 143
niaccurshi Avatar answered Sep 23 '22 20:09

niaccurshi


You'll need a local web server with a PHP interpreter to parse the PHP code. There are a few to choose from. I personally use WAMP. Once it is installed place your php files in wamps www folder and browse to it in your browser using http://127.0.0.1/yourphpfilename.php

It should display the php output instead of the code then.

like image 22
CrazyCrisUk Avatar answered Sep 20 '22 20:09

CrazyCrisUk


PHP file must be interpreted by web server (you may use XAMPP, which is popular set of servers for Windows including Apache HTTP server, MySQL database server and PHP extension for Apache).

Server executes PHP code and sends script output/result via http protocol to web browser.

Opening that file via filesystem is bad idea, because PHP file will be read as plain text if it is not processed by web server with PHP.

It looks like, you dont understand how PHP works. You need to read some books about web fundamentals.

Eventually you can visit http://thenewboston.org or http://phpacademy.org - they have very good educational videos.

One more advice to consider:

In my personal opinion Dreamwaver is very bad tool for learning PHP. For learning purposes I recommend to use Notepad++ or some other IDE (maybe NetBeans PHP edition). It will help you to understand more.

How to debug php code in dreamweaver cs5?

like image 34
Kamil Avatar answered Sep 24 '22 20:09

Kamil