Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a php/mysql form to be embedded on many different websites

Tags:

jquery

php

I am not sure where to start, and would appreciate it if someone could point me in the right direction. I would like to create a simple form 'widget' for embedding on different websites.

The idea is that the form reside on my server, and the form information will be submitted to the database on my server, but will be embedded on other sites.

** The form has dynamic drop down menus that populate based on $_GET variables. For example, if I were using an iframe it would look like this...

<iframe src="http://www.example.com/form.php?id=555"></iframe>

Should I use an iframe or would javascript be better for this, is there a better way? What are the security concerns that I need to look out for?

like image 624
superUntitled Avatar asked Mar 21 '11 18:03

superUntitled


1 Answers

Your best solution for this would to use an iframe.

The reason you cannot do this with javascript is because of most browsers security policy regarding cross site scripting.

With an iframe, you will be able to provide the end user a URL and then they would be able to position the frame anywhere they'd like. I imagine you would provide a URL with a specific path for each user, or a variable to define the user.

Something like:

<iframe src="http://yourdomain.com/form/?clientid=12345&style=woodgrain"></iframe>

One of the problems with the browser origin policy is that the website owner will not be able to style your forms themselves, nor will they be able to manipulate the DOM within that iframe in any way. This might actually be a blessing or a curse for you, depends on the circumstance.

If you need action after the form is submitted, you can always have the site use a script with a function that does nothing during the first iteration, but on the second iteration changes the iframe source, or even removed it from the DOM of the parent site. This would be done via an onLoad="" action in the iframe tag.

like image 115
David Houde Avatar answered Sep 28 '22 22:09

David Houde