html website - integrate php?

by 9 replies
11
I have a html website for my business which suits me fine.

I have just found a really nice php script for an enquiry form and would like to add it to my site on an exsiting html page.

Is this possible without turning it into php page as this would change the url from contact.html to contact.php and i dont want to do that.

So the main question is how to go about achieving this?
#website design #html #integrate #php #website
  • It is possible to allow PHP code in the .html files using .htaccess. I have never done this so I do not know the code but it should be possible to find it in google easily.
    • [1] reply
    • PHP code will not run in a .html page... the page has to have a .php extension.

      That said, most contact forms I've seen don't require the page that's submitting the info to be PHP. Usually only the page that is receiving the info (the script) has to be PHP.

      If that's not the case with the script you like though, then what you can do is change your contact.html page to contact.php (just rename the page's extension from .html to .php), and then use .htaccess to redirect contact.html to contact.php.

      That way when someone goes to contact.html, it will automatically send them to contact.php (that way you wouldn't have to worry about updating any hyperlinks that were pointing to your old contact page).

      If you want to do that, the .htaccess code would be...

      • [1] reply
  • [DELETED]
  • If you don't want to change html file to php file then you put <form> tag into your contact.html file
    then you need to write php file to recieve data from contact.html and redirect to thankyou.html or page which you want.
  • Hello Nealh,

    Firstly create a contact.php page and paste your script which have you found. Upload it on server then use this code in .htaccess file

    "RewriteRule ^contact.html$ contact.php [L]"

    Thanks
    Marcus
  • thanks for the replies people.

    I shall try using the .htaccess file to allow me to write php in my html page as per the article posted by nesterdwarf. Thanks
    • [1] reply
    • There's a good chance you will have problems. If not right now, then the next time php is updated. I tried this a couple of years ago. Altogether I got about 6 different versions of ways to do it with the .htaccess file. 3 from this forum, and 3 from my host.

      None of them worked on my site. Apparently they had worked on earlier versions of php.

      It's certainly worth trying. If it does work, let us know, but I'm losing my interest in doing it this way. Personally I'm just going to use redirects and change my remaining html pages over that way. It has the advantage that while I'm at it, I can reorganize with more folders.
  • [DELETED]

Next Topics on Trending Feed

  • 11

    I have a html website for my business which suits me fine. I have just found a really nice php script for an enquiry form and would like to add it to my site on an exsiting html page.