[RESOLVED] Pass data via the URL
I have a web form created in front page for example
<a shape="rect" href="mailto:firstname.lastname@example.org" shape="rect">example.com/update-mail.htm
on it is a field called eMail. I want to pass data to this field via the URL.
I have tried
<a shape="rect" href="mailto:example.com/update-mail.htm?eMailemail@example.com" shape="rect">example.com/update-mail.htm?eMailfirstname.lastname@example.org
but although we didn't get an error, it didnt appear to populate the field.
Do I need to do something else ?
Also if I wanted to pass two fields - what would the syntax be.
Would be good to see the form....
and why are you using "mailto:" in the link??
...but stupidity is terminal.
Wow! Fast reply. Thanks!
Without mailto: it's going to work?
I can send you the code right now because I'm at work. I will post the code later. Thanks a lot for reply.
What I have tried is http://www.mysite.com/myform.htm?Reccid=123456 to populate the field called Reccid, but nothing appears in the field - I hope this clarifies things.
Originally Posted by opifex
When you say "populate a field", do you mean you want the actual form element on the page to be pre-filled with the data in the URL? I don't understand what you are trying to do.
If you have a page called example.php and you want to send data to the script via the URL, use the following syntax:
Then within example.php you can access the values via the $_GET superglobal:
So to pre-populate a text field:
echo $_GET['variable1']; // foo
echo $_GET['variable2']; // bar
echo $_GET['answer']; // 42
Bear in mind that that you should always validate data before outputting it like this. It is less dangerous in a textbox, but if you are echoing user input directly you leave yourself open to a variety of attacks.
<input type="text" name="somefield" value="<?php echo $_GET['variable1'] ?>" />
Thanks a lot ! It was perfect! It works! Thank you!
Originally Posted by Mindzai
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread