Solved

How to go back to respective previous screen ?

Posted on 1998-06-06
11
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

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