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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is it possible to get info from previous page form, without submitting

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034
0
0
i have a form on one page and once it's submitted, the page it goes to reads the fields through:

$field1info = $cgi->param('field1');
$field2info = $cgi->param('field2');
etc...

no problem. but what if i didn't submit to get to the parse page, and instead simply click a link to get there? how can i still access those fields? is this possible.

thanks!

- g
 
besides the obvious query string, name value pairs.

- g
 
You still access the fields the same way as you posted. Providing of course you add them to the query string like travs69 has shown above.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
what i'm trying to do is avoid the query string setup.

i already knew i could do that.

here's the situation:

i have a signup form (log.pl), and when complete, the user submits that form to log.pl...because of a hidden value in the form, the log.pl file knows to not show the form this time but to process the form and display the results. this works great.

the problem is that the user can hit the back button and go back to the form.

if i don't submit the form but only link to the file, the back button can't be used.

so i'm trying to avoid submitting the form, but still access the form elements.

any ideas?

please just stick to the topic, not the logic (or lack of) in my setup, unless it adds and not discredits.

- g
 
You want to get the form data without submitting the form? If you find out how let us know.

please just stick to the topic, not the logic (or lack of) in my setup, unless it adds and not discredits.

That comes across as sounding very condescending.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
if i don't submit the form but only link to the file, the back button can't be used.

Huh... you are disabling the back button via a link?

You are trying to control the way the browser is designed to function. It is going to cache your data and if you hit back it is going to display "stuff". I have heard ajax solutions will fix this.. but can't say for sure personally.


As for this:
please just stick to the topic, not the logic (or lack of) in my setup, unless it adds and not discredits.

I would suggest being a tad more friendly to the folks who are basically doing your work/research for you, but of course that's my opinion.

 
If your goal is to prevent the person from submitting the form again, you could use a javascript function to disable the submit button immediately after it is clicked. Or you could set the page to expire immediately so that the page won't reload when the back button is pressed.

Is that what you want?
 
There is a design pattern that addresses this issue (might be 'Sentinel'), which requires you to maintain a session on the server.

Store a counter in the session, which you increment each time you serve up a page. Embed the counter in a hidden field on each page. Each time your server gets an HTTP request, compare the hidden counter in the received page with the one held in the session. If they match, then you have the page your server is expecting. If not, then it means your user hit the back button, and you can handle this in a way that is appropriate for the application.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
From what I know, there are 4 ways you can pass data between pages.

1. GET
2. POST
3. COOKIES
4. SERVER SIDE DATA STORAGE

From what I know, there is no way to hide values in a GET and any values you 'hide' in html and pass with a POST can easily been seen by simply viewing source. COOKIES data can be effectively hidden if you encrypt the data but theres a lot more coding required. I might suggest you cookie session or page data and store the confidential information server side. If the goal is to forbid a double posting there are ways around this as well. I like the javascript option that would remove or grey out the submit button. You can also do recursive checks to your datafile prior to posting ...
 
Use a cookie to save a time stamp. If they try to re-submit the form, you'll know and can prevent re-submission.

Time stamp:
($Second,$Minute,$Hour,$Day,$Month,$Year,$WeekDay,$DayOfYear,$IsDST) = localtime(time);

Cookie:
print "Set-Cookie:tstamp=$Second$Minute$Hour$Day$Month$Year {'tstamp'}\n";

Shameless plug: Please answer my question, too:
 
Don't ever put anything in a cookie other than a session ID. Cookies are easily editable and you should always use them in conjunction with session's (unless of course you want your site hacked.. if so just ignore that information).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top