Solved

cant read html

Posted on 2014-04-26
15
247 Views
Last Modified: 2014-05-08
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
Comment
Question by:jagguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +2
15 Comments
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 40024510
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
 

Author Comment

by:jagguy
ID: 40024524
yes I know this but my question was to change the html file so it can read php commands.
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 40024530
Rename it as php.
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 110

Expert Comment

by:Ray Paseur
ID: 40024549
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
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 40024570
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
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 40024582
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
 

Author Comment

by:jagguy
ID: 40025195
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
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 40025239
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
 
LVL 29

Expert Comment

by:chilternPC
ID: 40025627
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
 

Author Comment

by:jagguy
ID: 40028388
I should have said I dont have dreamweaver so the next best option for templates with php is?....
0
 
LVL 29

Expert Comment

by:chilternPC
ID: 40028476
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
 
LVL 29

Expert Comment

by:chilternPC
ID: 40028480
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
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 40028884
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
 

Accepted Solution

by:
jagguy earned 0 total points
ID: 40039884
I have answered this question with my host provider and i need to change the settings
0
 

Author Closing Comment

by:jagguy
ID: 40049826
i answerd it
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question