Get template from customers site...Insert your forms

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Get template from customers site...Insert your forms

Post 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?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Looks like curl() is better then fopen().
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post 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()?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post 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.
Post Reply