Solved

How to go back to respective previous screen ?

Posted on 1998-06-06
11
217 Views
Last Modified: 2013-12-25
Set up:
OS : Windows NT 4.0
Web server : Netscape Enterprise server
CGI scripts : Perl

Note : Not using Java script or VB script.

Problem description :
I have to add record to the database. From two different place user can come to add screen, after user pressing commit button it has to go back to the previous screen from where it came to add screen.

By pressing submit button (only) one script will be called this script should handle commit of the record to the database as well to generat the previous screen. How to do this ?

If I keep all the code required to generate the previous screen in the add-commit scripts it is not good way of doing it.

Other way is, in add-commit script execute the respective script (previous scripts). If it is good way then can any one tell me how to do it in perl script with small example ?.

Add-commit script has to do,
1. Validate the form fields (add screen's)
2. If error, generate add screen again and exit
3. If correct, insert a record to database
4. Generate previous screen (dynamically) by executing that script in add-coomit script.

Doubt : Is one perl script can execute another perl script in the CGI scripting without any problems (like security) ?


other good solution are expecting from experts with implementation details.
0
Comment
Question by:Govinda
11 Comments
 
LVL 5

Expert Comment

by:icd
Comment Utility
If I understand correctly, you have one script that handles input from two different input forms. You want to put a 'back' button on the results page of the script to go back to where you came from.

One way you can do this is to have a hidden field in each of the input forms.

<input type="hidden" name="backto" value="/yourdomain.com/thispage.html">

(Changing the 'value' of course to point to the url of each page).
You can then use this value in your script to provide the url in the 'back' button.

0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
Why no javascript?

Michel
0
 

Author Comment

by:Govinda
Comment Utility
Hi icd,
I have to have hidden variable to know from where i came to add screen (as u suggested). But my question is, in the add screen user will give the data, this data has to be validated and inserted in the db (if very thing is ok). After that it has to generate previous screen, actuall it has to show all the record even newly inserted record.

Note : Two previous screens are generated by a script not static HTMLs.

How to implement ?
0
 

Author Comment

by:Govinda
Comment Utility
Edited text of question
0
 

Author Comment

by:Govinda
Comment Utility
Edited text of question
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Expert Comment

by:icd
Comment Utility
How about making the script that generates the 'previous' screen a subroutine? That way you don't need to include the same code in two different scripts.

The files would then be:-

routine.pm   Your script to generate the 'previous' screen
original.pl  Simple script that 'requires' routine.pm and calls it to generate the page.
validate.pl  Validate your input, 'require' routine.pm and calls it if necessary.

I assume you are using Perl 5.

0
 
LVL 5

Expert Comment

by:icd
Comment Utility
One other possibility. Just have one script.

First time through (detected by cgi variables, i.e. no 'submit' cgi variable) the script outputs the screen showing the database data together with the form.

The 'action' part of the form data output by this script simply refers to its own URL.

On finding an input cgi variable associated with the 'submit' button the script can validate the data, update the database and output the data.

On finding an error it can output an alternative page explaining the error.

Put the various output functions in subroutines to make the code easier to follow.


0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
Use the HTTP_REFERER to see where the form was submitted and redirect in you cgi script the user back to that url.


0
 
LVL 1

Expert Comment

by:slinky
Comment Utility
Why not do a JS history.go(-1) ?
0
 
LVL 1

Accepted Solution

by:
RoboBob earned 100 total points
Comment Utility
From your cgi script, after the processing is done and you want to send them back to the old page, do this (example in perl, but it should work similarly in whatever language you are using)...

print "Location: $ENV{'HTTP_REFERER'}\n\n";

this will redirect them back to the page they came from...
0
 

Author Comment

by:Govinda
Comment Utility
Thanks a lot to every one.
Problem being solved long back because of
project pressure i forgot this, I am sorry for the delay.

Thanks,
Govinda

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to dynamically set the form action using jQuery.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now