Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grab variables from database and push through 2 pages

Status
Not open for further replies.

gabrielfuller

IS-IT--Management
Feb 18, 2004
30
US
I have developed an application program for some friends. People go and apply in the end user section, the form inputs the texts into a mysql db and then sends the users to another page.

I am trying to create an administration backend but am stuck on a specific part.

When i go to a specific link (modapps.php?id=$id), I want it to set the columns for that row, as variables. So say I have modapps.php?id=12... I want it to set the column named fname as variable named $fname so that I can display it in a form link to and update mysql application.

Does anyone know how I can do this?

Gabriel Fuller
Teen Mania Ministries
 
Use the global $_GET array.

when you have an URL something like


you can access each and every one of those items in the URL using $_GET it is a superglobal meaning that it is available everywhere in your script.

with the above example:

$_GET['id'] == 10
$_GET['act'] == 3
$_GET['name'] == 'bob'
$_GET['auth'] == true

Also if you are using the POST method from a form you can use the superglobal $_POST the same way.

BIG WARNING
if you are using User input to create queries to your database be careful about cleaning the input data so that you don't allow SQL Insertion.

JRSofty
 
What really is your question?
You seem to be able to put the data into the table - so I assume you are also able to read the data from the MySQL server.
Please elaborate a bit on where you get stuck.
 
I am trying to push it onto a page that says, ok here is the information you entered, if this is correct then press submit.

Do you understand?

Gabriel Fuller
Teen Mania Ministries
 
Allright.
1. Display the information for the user to inspect.
2. Populate hidden fields <input type="hidden" name="myVar" value="myValue"> with the submitted data surrounded by a form tag.
This way you can show and pass the values on.

Another solution would be sessions. There is a whole chapter on sessions in the PHP manual.

For a quick, small script the first hidden field solution seems ideal.
 
that's not a problem. multiple ways to achieve this:

1. in the form submission page, serialize the POST variables (or GET vars - depends on method) and either push the resultant string into a hidden field on the next page or into a session variable (if you are using sessions). in either scenario you could set individual session variables to match each incoming post/get variable but this is more coding than you need.

2. use the POST variables (or get...) at the same time to populate the confirmation page.

3. on the confirmation page put the confirm button inside the form with the hidden field containing the serialised variables (or don't if you are using sessions).

4. on the final page (the one you get to by pressing confirm) unserialize the incoming post variable from the hidden field and process the data into your database. same is true if you are using sessions.
 
are you comfortable with the advice. i could probably dig up some example code if you are not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top