×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

HOW TO RE-DIRECT FROM CGI FILE TO HTML FILE

HOW TO RE-DIRECT FROM CGI FILE TO HTML FILE

HOW TO RE-DIRECT FROM CGI FILE TO HTML FILE

(OP)
Hi everyone,

Currently i am doing a server side scripting of cgi.

I have an html page whose action on SUBMIT is directed to a .cgi page which re-directs back to another new html page based on the condition.

contents of test.cgi:
--------------------

print "Content-type: text/html\n\n";

print "Hello, world!\n";

Thnx in advance,
Vishnu
#print redirect("http://10.140.5.30:8080/Result/Report.htm");

#print "Location: 'http://10.140.5.30:8080/Result/Report.htm';

The "HELLO WORLD !" static text is printed but the re-direction command both "redirect" and "Location" failed to re-direct the page.

RE: HOW TO RE-DIRECT FROM CGI FILE TO HTML FILE

Hi

The Location is a HTTP header. So if you send content before it, that will not act as HTTP header anymore.

CODE

print "Content-type: text/html\n";
print "Location: http://10.140.5.30:8080/Result/Report.htm\n\n";

print "Hello, world!\n";

Feherke.
http://rootshell.be/~feherke/

RE: HOW TO RE-DIRECT FROM CGI FILE TO HTML FILE

same with the redirect() function of the CGI.pm module. You can't print an HTTP header before trying to use it.

RE: HOW TO RE-DIRECT FROM CGI FILE TO HTML FILE

(OP)
I would like to execute some of the perl functions and then redirect to a different html file.

Say in a cgi file: test.cgi

&upload;
&workonreport;
<redirection code should come here>

After executing the functions, the redirection should happen.



Vishnu

RE: HOW TO RE-DIRECT FROM CGI FILE TO HTML FILE

(OP)
Even if i use the header as mentioned by Feherke..i get the following result in the browser..

"Status: 302 Moved Location: http://10.140.5.30:8080/Result/Report.htm "

I dont see the Report.htm page.

Vishnu

RE: HOW TO RE-DIRECT FROM CGI FILE TO HTML FILE

Hi

Did you removed the second new line ( \n ) from the Content-type header line's output ?

Feherke.
http://rootshell.be/~feherke/

RE: HOW TO RE-DIRECT FROM CGI FILE TO HTML FILE

Hi

If you want to see the Hello message before stepping forward, use the Refresh HTTP header :

CODE

print "Content-type: text/html\n";
print "Refresh: 3;url=http://10.140.5.30:8080/Result/Report.htm\n\n";

print "Hello, world!\n";
Where the 3 is the time to wait in seconds.

Feherke.
http://rootshell.be/~feherke/

RE: HOW TO RE-DIRECT FROM CGI FILE TO HTML FILE

(OP)
It worked feherke . Thanks a lot.

Vishnu

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close