Page 1 of 1

Get template from customers site...Insert your forms

Posted: Sun Feb 13, 2005 10:35 am
by hawleyjr
I have customers who want access to my secure forms. However, they want the page to appear like it is till on their site. The easy solution is to use frames however, I don't care for frames and that would require too much design effort on my customer. On top of that you loose the secure https in the address bar and the lock in the status bar of my secure forms page. Here is what I was thinking; I'm just looking for suggestions to move forward...

Have my customer design a template page. In the body of the page where the forms should begin insert comments such as <!-- forms start here --><!-- forms end here -->

When a form is called grabs that template and inserts my form HTML between the above comments. Presto...it should work.

Is fopen() the best function to grab the external HTML?

Is there a better way to do this?

Posted: Sun Feb 13, 2005 10:43 am
by hawleyjr
Looks like curl() is better then fopen().

Posted: Sun Feb 13, 2005 10:44 am
by feyd
I'd suggest caching their template on your server, just so you don't have to make an external page request every request, which will slow down the page response in various times. file_get_contents() is probably the better function to use if you have access to it. Otherwise, fopen works, however you cannot do a filesize() on it. .. and of course, regular expressions are probably best to switch out the form.

Posted: Sun Feb 13, 2005 10:47 am
by hawleyjr
I thought about storing a copy on my server. I just didn't want to worry about making sure it is up-to-date. What about using curl()?

Posted: Sun Feb 13, 2005 10:53 am
by feyd
you can use a cron or other schedule to make sure it's pretty new...

curl may incur a lot of overhead you don't need. If you needed to post or parse header information in the response, then curl is the sure thing. But for a simple page request, file_get_contents() does the job quite well. You do need to have fopen URL wrappers on though, but most hosts have that on already.

Posted: Sun Feb 13, 2005 10:59 am
by hawleyjr
I'm going to take your suggestion use file_gets_contents() and store them on my server running a cron job every 24 hr.

Thanks Feyd.