Mobile app version of vmapp.org
Login or Join
Welton855

: Server outputs the sourcecode of PHP page I have a Shared Hosting package with HostGator. In it, I'm hosting around 4 websites. They are just some simple sites that doesn't likely to attract

@Welton855

Posted in: #Php #Server

I have a Shared Hosting package with HostGator. In it, I'm hosting around 4 websites. They are just some simple sites that doesn't likely to attract more visitors. But a few days ago, when I accessed one of my sites(via a browser), it outputted the PHP code of index.php, instead of outputting it as HTML.

I think, at that time, the server was a bit busy or something. I heard that, Facebook also have got a similar condition where the home page's code was made available.

So, how do I take preventive measures for this ?

I always use phpBB forum's style of coding. That is, each sub pages, common functions, etc. are separated into subfolders. And in PHP, I would just include_once() or require_once() it. Also, these subfolders have a .htaccess file in which I have set the deny permission to the files inside it from outside.

Also, in the main page(index), I would define a constant. And the first line of the subpages(which is situated in separate folders) is to check whether this constant is set. If not, calls die().

I am looking forward for solutions to this problem of outputting raw code when the page is accessed.

Thanks in advance :)

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Welton855

1 Comments

Sorted by latest first Latest Oldest Best

 

@Rivera981

Is this a consistent problem or a 'here and there' type issue? Also, is the code being executed?

If it is a consistent problem, then you might want to check up on your host's PHP settings. PHP is exclusively a Server-Side language, meaning that what you request a page through your browser, and if the file is a .php (And PHP is installed on the server), the server will execute the code before sending the file to the client computer.

If the PHP code is being displayed in the source on the client machine, there is most definitely a problem with the server - not the code. The server shouldn't be sending the code to the client in any case, and I haven't heard of Facebook having that problem with their homepage.

Email HostGator's customer support and see if there has been any other issues with this reported with their system.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme