?
Solved

How to go back to respective previous screen ?

Posted on 1998-06-06
11
Medium Priority
?
241 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
Stack Overflow Podcast - Developer Story

Welcome to the Stack Overflow podcast recorded Thursday July 20 at Stack Overflow Headquearters in NYC. Your hosts today are podcast regulars Jay Hanlon, David Fullerton, and Ilana Yitzhaki, plus the quite irregular Matt Sherman (Stack Overflow Engineering Manager extraordinaire)

 

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 200 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
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…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Suggested Courses

800 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