LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-07-2003, 02:51 AM   #1
Robert0380
LQ Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Rep: Reputation: 47
PHP, passing a lot of variables to another page


Here is what I have:

I collect a lot of data from a registration page:

http://gigahurts.net/gtsbe/career/registration.html


when i get that data, i display a page that shows everything the user entered to the user (that part wont work if u look at the site).


What I have so far is a php page that gets everything they entered from the $_POST variable in php.

What I want to do is put a "Confirm" button and a "Back" button on the page so that if they hit "Confirm" it will add the information in the database and show another page that says "Thanks for registering" and what not or if they hit "Back" it will be the same as hitting the back button (i'm thinking of just settling for telling the user to use the back button).

The question: How do I pass all of my created variables (its a lot of em) to the next php page without a whole lot of hassle?

I could just add everything to the database on Submit, but I really need the confirm page 1st.
 
Old 09-07-2003, 03:03 AM   #2
Robert0380
LQ Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Original Poster
Rep: Reputation: 47
just thought, this would be a nice time for there to be transaction support in MySQL. then i could just do a commit on confirm or a rollback on "back". but MySQL doesnt have that, so no go on that idea..and it would probably not be a good idea but this page wont get more than 30 or 40 hits in a 4 month period.
 
Old 09-07-2003, 04:25 AM   #3
Robert0380
LQ Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Original Poster
Rep: Reputation: 47
ok i think i figured it out:


i can do this:

<form action= <?php add_to_database() ?>


and on "submit" it will call the function add to database which contains my "INSERT" statement and it can return another page that displays the "THanks" page, like so:

function add_to_database(){
//databse code here
return "thanks.php"
}

so what should happen is, the stuff gets added to the database, and then the form tag becomes:

<form action=thanks.php>

and it should work.


hmmm, could even do my error checking inside that method too.

Last edited by Robert0380; 09-07-2003 at 04:56 AM.
 
Old 09-07-2003, 04:31 AM   #4
paulg
LQ Newbie
 
Registered: Sep 2003
Location: uk
Distribution: suse 8.1
Posts: 14

Rep: Reputation: 0
You said
Quote:
"How do I pass all of my created variables (its a lot of em) to the next php page without a whole lot of hassle?"
Glib answer is:

Dont let them off the page (client-side) until they confirm the details.

Use javascript confirm box, list their replies - this then automatically has OK / Cancel buttons.

try javascript.internet.com - check out what users are doing there (search for "confirm")

Using a back button is bad news with php, you will have users accidently going back and forth creating duplicate entries in your dbase. Mostly I dissallow going back by stopping cacheing of the page.

Another way is to add the entry into the db (server-side) and instead of back/forward buttons display their input back into a form again (not just echo'd onto the page) - thus allowing them to edit/return to start. If you are clever you will re-use the original form. (I'm not that clever)

Theres lots of other ways..

Depends on your app - this is all standard stuff - I would advise you buy a good book that takes you through all the options though.

I like the js way because it is easier for the user - stay on the page, immediate feedback, do some basic validation too.

Ideally you would do both client and server side - though server side I use mainly to sanitise the incoming vars.

Paul

Last edited by paulg; 09-07-2003 at 04:39 AM.
 
Old 09-07-2003, 04:44 AM   #5
paulg
LQ Newbie
 
Registered: Sep 2003
Location: uk
Distribution: suse 8.1
Posts: 14

Rep: Reputation: 0
Sorry,

as your monologue develops I see you dont want users to verify their own input. I didn't read it properly.

Paul
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing variables to an include? Red Squirrel Linux - Software 4 09-23-2005 09:18 PM
PHP passing variables from url to ... latino Programming 3 08-31-2005 06:35 PM
passing variables by reference in javascript djgerbavore Programming 2 06-07-2005 11:34 PM
passing variables to sed jjfate Programming 8 07-31-2003 04:15 AM
Passing variables in PHP???? vous Programming 3 03-20-2003 06:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration