Re: Click link to go to routine
- From: Joe Smith <joe@xxxxxxxxx>
- Date: Wed, 09 May 2007 12:29:25 -0700
Sykigh A Trist wrote:
Thanks to all that replied. Some helpful tips from you. I will try to put to use what you have given me. And about my tirade (see below from my first post).
Can this be done within this code and does anyone mind showing me how to do it? Thanks
The reason I put the words above in my first post is because it is hard to get any answers from a few in this newsgroup. I've been here before. Same thing, last time I was here. Some people, instead of trying to help, like to point out how wrong you are in every aspect of your question. It was a very simple question - I want to click on a link and go to a subroutine in the code and not to a webpage. Again, thanks to all that helped.
We're trying to help, but you've added added restrictions that make it
impossible to provide an answer to the problem _as_it_is_stated_.
Here is an outline for a solution that works, as long as you drop the
"not go to a webpage" restriction.
1) One way or another, the user gets to a URL that goes to server ALPHA
That web server executes perl program A.pl which includes
a print statement. That print statement outputs a clickable URL, like
'<a href="http://BETA.example.com/cgi-bin/B.pl?part=2">continue to step 2</a>'.
The process running A.pl terminates after outputting the HTML.
2) The user clicks on the link. The user's browser sends a GET request
to server BETA. This is a process that goes to a web page.
3) Server BETA executes perl program B.pl which looks at the information
the browser sent, and executes a specific function inside the B.pl program.
Program B.pl outputs a response, since the browser is expecting one.
if ($part == 2) {
print return_this();
}
In many cases, servers ALPHA and BETA are this same.
With a little program logic, program A.pl and program B.pl can be the same.
However, you cannot get around step 2. When a user clicks on a link,
(and JavaScript is not in the picture), then the user's browser _MUST_ go
to a web page. This means a new request to the web server, a new process
running on the web server to execute B.pl (A.pl with additional arguments).
a) "use CGI;" or other standard module for parsing POST or GET requests.
b) When your program detects that it has been invoked without arguments,
output a FORM or a link that can be clicked on.
print qq{<a href="http://www.scripts.net/cgi-bin/A.pl?back=true" target="_top">
Go Back</a>\n};
c) When your program detects that it has been invoked with the right arguments,
go to a specific routine in the code.
if ($back eq 'true') {
return_this();
} else {
print "Content-type: text/plain\n\n Oops! Wrong link was selected\n";
}
> It was a very simple question - I want to click on a link and
> go to a subroutine in the code and not to a webpage.
You want to click on a link that goes to a webpage that executes a
particular subroutine in the code. Same program as before, but a fresh
new instance with all new unset variables.
> Re: Click link to go to routine
Answer: Click link to invoke CGI program on a server with the idea that
the CGI program will go to a specific routine.
-Joe
P.S.: Don't forget that the second execution of your code will not have access
to any of the variable values that the first execution set, unless you store
temporary results in a file, a database, cookies, or hidden FORM parameters.
.
- References:
- Click link to go to routine
- From: Sykigh A Trist
- Re: Click link to go to routine
- From: Sykigh A Trist
- Click link to go to routine
- Prev by Date: Re: Click link to go to routine
- Next by Date: Re: Converting 4 bytes to a float
- Previous by thread: Re: Click link to go to routine
- Next by thread: FAQ 4.52 How do I sort an array by (anything)?
- Index(es):
Relevant Pages
|