Form Pre Population

How do I auto populate a field in a form, depending on what page I came from?
LVL 7
rgranlundAsked:
Who is Participating?
 
Ray PaseurConnect With a Mentor Commented:
OK, here is one way to go about it.  Let's say you are on the "Quote" page.  Make your link to the contact.php page look like this:

<a href="contact.php?frompage=Quote">Contact Us</a>

Then in the contact.php page, you can get the string from $_GET["frompage"] and use it in a hidden value of the form, something like this:

<input type="hidden" name="frompage" value="<?php echo $_GET["frompage"];?>" />

When that form is submitted it will carry the "frompage" data right into the action script where you can find it in $_REQUEST.
0
 
Ray PaseurCommented:
What data do you want to put into the form - where will you get this?  Do you know about HEREDOC notation?
0
 
rgranlundAuthor Commented:
I f I am on a page called / named Quote, and I click on contact us in the form, the subject will say Quote.
If I am on a page called More Information and I click on Contact us, in the form subject it will say More Information.
0
 
rgranlundAuthor Commented:
This is what I have already discovered, by actually thinking about.

Can I use POST as effectively?

0
 
Ray PaseurCommented:
Can I use POST as effectively? -- Not sure.  GET variables are in the URL.  POST variables are in the POST method form.  REQUEST variables could come from either source.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.