[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Form Pre Population

Posted on 2011-04-28
5
Medium Priority
?
254 Views
Last Modified: 2012-06-21
How do I auto populate a field in a form, depending on what page I came from?
0
Comment
Question by:rgranlund
  • 3
  • 2
5 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35485810
What data do you want to put into the form - where will you get this?  Do you know about HEREDOC notation?
0
 
LVL 7

Author Comment

by:rgranlund
ID: 35486732
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
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 35487003
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
 
LVL 7

Author Comment

by:rgranlund
ID: 35487117
This is what I have already discovered, by actually thinking about.

Can I use POST as effectively?

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35488882
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question