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!!

3
  • php.about.com/od/advancedphp/p/html_php.htm Commented Dec 11, 2013 at 5:35
  • Wow. Thank you, can I ask you one more php question on here without posting a new question? Commented Dec 11, 2013 at 5:38
  • I'm adding this little php thing to my site: 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) Commented Dec 11, 2013 at 5:40

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Wow, thanks for the quick response. Can you elaborate a bit more? I have never fiddled with htaccess to be honest. Thanks again!
You can put rewrite rules in htaccess to rewrite request to particular url to different one. Have a look at this stackoverflow.com/questions/5990240/…
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

Comments

0

Easy way to use object

 <object name="foo" type="text/html" data="foo.inc"></object>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.