• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

cant read html

Hi, In my file called home.html this doesnt work unless I rename the file home.php

How do I make the html file pick up the php file with cpanel?

  <div class="row-fluid">
      <div class='span12'>
       <?php include('includes/header.php'); ?>
     
   

       </div><!--span12-->
      </div> <!--row fluid-->
0
jagguy
Asked:
jagguy
  • 5
  • 3
  • 3
  • +2
1 Solution
 
Dan CraciunIT ConsultantCommented:
If you name your file home.html then the server cannot know that you have php code inside and it will print everything.

You have to name the file home.php so the code is parsed.

If you're referring to the home page of your site, then that should be called index.php and it will be displayed when navigating to http://yoursite.com/, if you do not have a index.html or index.htm.

HTH,
Dan
0
 
jagguyAuthor Commented:
yes I know this but my question was to change the html file so it can read php commands.
0
 
Dan CraciunIT ConsultantCommented:
Rename it as php.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Ray PaseurCommented:
Here is an excerpt from my .htaccess file.  Very useful for working with HTML documents that just need a little bit of PHP :-)

AddType application/x-httpd-php5 .html .htm .php

Open in new window

0
 
Julian HansenCommented:
File extensions exist for a reaon - they are used to give context to the file and specifically what applications can operate on them.

When you start changing the default behaviour you can create confusion.

It is expected that .html files are processed as such and .php files are passed to the php processor.

The question you need to ask is why do you want to do this.

If there is a genuine reason for needing to keep the file as a .html then first consider url rewriting. In your .htaccess enter a rule to rewrite your .html call as a .php call.

This way you expose the file externally as .html file but anyone looking at the code base will be able to see that index.php is a file that contains php script whereas a .html file will generally be overlooked as a file containing code.

To create a rewrite url in your .htacess just do as follows
RewriteEngine on
RewriteBase /

RewriteRule index\.html$ index.php [L,NC,QSA]

Open in new window

0
 
Ray PaseurCommented:
You don't have to change your HTML + PHP documents at all.  Please read this from the online man pages and then post back if you still have questions:

http://php.net/manual/en/security.hiding.php
0
 
jagguyAuthor Commented:
OK why I need to do this is that for a website it is easier to have a template with header, menus and footer and just use this for all webpages.
Using includes with php is what you do.

Dreamweaver allows you to do this but I dont like .
0
 
Ray PaseurCommented:
OK why I need to do this...
Erm, why do you need to put gasoline in a car for the engine to run?  It's the way to make it work, that's all.  You asked "How do I make the html file pick up the php file..." and this is the answer.  It's about as easy as we can make it.  And it's what the authors of PHP recommend.

Is there some reason why you don't want to do this?  If so, please explain.
http://php.net/manual/en/security.hiding.php
0
 
chilternPCCommented:
In dreamweaver create the template   main.dwt
then in that project  for the home page of a website create a new page based on the main.dwt  template  and save as ..   index.php
in dreamweaver you can set up defaults when creating projects so it will save it to the correct file extension save you having to manually save it.

upload to website and the server will execute the code in the file.

the answers above are all correct, if you use php code in your file you need to call it   <filename>.php not <filename>.html.  The web server will know what to do.

In the dreamweaver project if you rename the file, it will update all the references to that file if the file is  used in the files of that project  and then upload all the files that reference it.
0
 
jagguyAuthor Commented:
I should have said I dont have dreamweaver so the next best option for templates with php is?....
0
 
chilternPCCommented:
I assume you are happy with why your question about the HTML file is not being executed by the PHP engine? and now need to know how to template your PHP website?

what experience do you have in website design and PHP ? - this will help us determine what answer to provide  and what sort of website do you want to create?

from simple flat multi page website to dynamic content from a database  website to a framework website using  wordpress or joomla or even synfony
0
 
chilternPCCommented:
this link provides an overview of what PHP framework is  its goes beyond simple tempting of php code and turns a PHP website into a maintainable, extensible system,   I wouldn't build a framework I would use one that widely used.  (synfony, Yii, Smarty or CakePHP)  this article uses TWIG to build an example

http://www.smashingmagazine.com/2011/10/17/getting-started-with-php-templating/
0
 
Julian HansenCommented:
If you are interested in a very simple PHP template (or just understanding how a PHP framework works) you might find this article useful

http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/A_13095-A-simple-PHP-master-Template-framework.html
0
 
jagguyAuthor Commented:
I have answered this question with my host provider and i need to change the settings
0
 
jagguyAuthor Commented:
i answerd it
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now