Solved

How to go back to respective previous screen ?

Posted on 1998-06-06
11
229 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
ID: 1829433
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
ID: 1829434
Why no javascript?

Michel
0
 

Author Comment

by:Govinda
ID: 1829435
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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

Author Comment

by:Govinda
ID: 1829436
Edited text of question
0
 

Author Comment

by:Govinda
ID: 1829437
Edited text of question
0
 
LVL 5

Expert Comment

by:icd
ID: 1829438
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
ID: 1829439
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
ID: 1829440
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
ID: 1829441
Why not do a JS history.go(-1) ?
0
 
LVL 1

Accepted Solution

by:
RoboBob earned 100 total points
ID: 1829442
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
ID: 1829443
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

808 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