.php file shows code in Chrome [closed]
Asked Answered
G

4

5

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

   ?>
Grefe answered 5/3, 2013 at 0:12 Comment(1)
You should read some tutorials or view some videos about PHP fundamentals. Maybe visit phpacademy.org or thenewboston.org or just read DreamWaver users manual...Cacogenics
S
9

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.

Soekarno answered 5/3, 2013 at 0:14 Comment(2)
Alright, I will go get this uploaded to my host. Thanks for the information!Grefe
It works on the web server. If you want to check it out it is hereGrefe
C
1

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?

Cacogenics answered 5/3, 2013 at 0:19 Comment(2)
"It looks like, you dont understand how PHP works. You need to read some books about web fundamentals." This is similar to pointing someone who doesn't understand something (or maybe even know what it is) at a library and saying "There are things that you don't know about web fundamentals and the answers are in there." How will they know where to start? If you could provide a more specific suggestion for what to research, it would be much more useful. Remember that "web fundamentals" is a very broad and non-specific subject.Crittenden
@Crittenden I don't understand your point. Answer to his question is on top of my post. Below detailed answer I just wanted to tell him, that he should use some "ready to use" resources with fundamentals. "How will they know where to start?" I guess from first page of tutorial... You can't learn everything by asking others about things explained very well in every book and tutorial about PHP. Trying to do something in PHP without knowing what PHP is bad idea too.Cacogenics
F
1

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.

Flange answered 5/3, 2013 at 0:20 Comment(0)
I
0

For execute that type of files you must have Apache (Web Server) + PHP (interpreter). It will be resolved by using something like XAMPP (you can google it.)

Incredulity answered 5/3, 2013 at 0:18 Comment(1)
Unfortunately dreamweaver could not execute this file. It only for design (Html, css)Incredulity

© 2022 - 2024 — McMap. All rights reserved.