Solved

cant read html

Posted on 2014-04-26
15
240 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
  • 5
  • 3
  • 3
  • +2
15 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
Comment Utility
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
Comment Utility
yes I know this but my question was to change the html file so it can read php commands.
0
 
LVL 34

Expert Comment

by:Dan Craciun
Comment Utility
Rename it as php.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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 51

Expert Comment

by:Julian Hansen
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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 28

Expert Comment

by:chilternPC
Comment Utility
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
Comment Utility
I should have said I dont have dreamweaver so the next best option for templates with php is?....
0
 
LVL 28

Expert Comment

by:chilternPC
Comment Utility
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 28

Expert Comment

by:chilternPC
Comment Utility
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 51

Expert Comment

by:Julian Hansen
Comment Utility
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
Comment Utility
I have answered this question with my host provider and i need to change the settings
0
 

Author Closing Comment

by:jagguy
Comment Utility
i answerd it
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to dynamically set the form action using jQuery.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now