0

I'm no genius when it comes to coding, but I google enough to figure things out... I have a quick question.

  1. I have a page "index.html", "events.html" etc... and I want to add <?php include('exitpopup.php'); ?> so that it loads and executes the php file. However, I do not want to have to rename my pages with .html to .php in order to do this... breaking all my links across my website.

Does anyone know a work around or can suggest a better way for me to do this? Many thanks!!

HoustonGuy
  • 167
  • 1
  • 1
  • 8
  • http://php.about.com/od/advancedphp/p/html_php.htm – hammus Dec 11 '13 at 05:35
  • Wow. Thank you, can I ask you one more php question on here without posting a new question? – HoustonGuy Dec 11 '13 at 05:38
  • I'm adding this little php thing to my site: http://www.tonylea.com/2011/creating-a-jquery-exit-popup/ Check out the demo to see... The only problem, is if you're down the page, and mouse breaks the browser, the pop-up won't go.... A guy suggested the fix in a comment below, but I keep getting an error when I fix the code in the php file. (sorry I had hit enter by accident) – HoustonGuy Dec 11 '13 at 05:40

3 Answers3

1

Use htaccess to rewrite request to yourfile.html to the newly created yourfile.php.

hanish.kh
  • 517
  • 3
  • 15
  • Wow, thanks for the quick response. Can you elaborate a bit more? I have never fiddled with htaccess to be honest. Thanks again! – HoustonGuy Dec 11 '13 at 05:36
  • You can put rewrite rules in htaccess to rewrite request to particular url to different one. Have a look at this http://stackoverflow.com/questions/5990240/redirect-all-html-extensions-to-php – hanish.kh Dec 11 '13 at 05:40
1

If you want to execute php code in .html file extension than u need to do some htaccess changes. Since file-extension plays a major role, it only tells the browser how to handle or parse a particular page.

You can create a .htaccess file at the root folder of your website and in the .htaccess file add this line:

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

If you only plan on including the PHP on one page, it is better to setup this way:

<Files yourwebpage.html>
AddType application/x-httpd-php .html
</Files>

This code will only make the PHP executable on the yourpage.html file, and not on all of your html pages.

If you are ok with changing your file extension to .php than your work will be quite easy.you can simply include a php code between html code.like this

<form method="get" action="latest.php">
<label><?php echo "hello" ?></label>
</form>

see here

detail

Community
  • 1
  • 1
R R
  • 2,999
  • 2
  • 24
  • 42
0

Easy way to use object

 <object name="foo" type="text/html" data="foo.inc"></object>
Muhammad
  • 3,169
  • 5
  • 41
  • 70