CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Content-type:text/html\n\n

 



perlkid
stranger

Feb 26, 2000, 10:37 AM

Post #1 of 5 (886 views)
Content-type:text/html\n\n Can't Post

 
Does anyone know a way that I can print html in a cgi program wothout the Content-type:text/html\n\n? Like if you were printing to the ENDHTML or endofhtml an you could stick the content-type in thier so that way it is isoloated from the rest of the program but it still works for printing html, I need to be able to print locations on the same program as html. So if there is a way to isoloate the content-type on a program so that the print location is not effected that would work great.

Thanks,

perlkid


Jasmine
Administrator / Moderator

Feb 26, 2000, 2:26 AM

Post #2 of 5 (886 views)
Re: Content-type:text/html\n\n [In reply to] Can't Post

Either way, if the end result will be printing to your browser, you'll need the Content-type: (something) line.

As long as the content-type line is the first line of output, you can print anything else that you want to the browser. The content-type can be text/html, text/plain, image/gif, etc., but the content-type line must be present before other output to avoid browser errors.

[This message has been edited by Jasmine (edited 02-26-2000).]


perlkid
stranger

Feb 26, 2000, 11:45 AM

Post #3 of 5 (886 views)
Re: Content-type:text/html\n\n [In reply to] Can't Post

 
Does that mean there is no way to print html and print location in the same program?

perlkid


darian
Deleted

Feb 26, 2000, 1:47 PM

Post #4 of 5 (886 views)
Re: Content-type:text/html\n\n [In reply to] Can't Post

If you want to print html code and do a redirect in the same program I suggest you create a header sub and then call it each time you want to do html code. That way you can also do a redirect.

example:

sub header {
print "Content-type:text/html\n\n";
}

if ($url) {
print "Location: $url \n\n";
}
else { &header; }
print qq~
Put your html code here!
~;



perlkid
stranger

Feb 26, 2000, 8:57 PM

Post #5 of 5 (886 views)
Re: Content-type:text/html\n\n [In reply to] Can't Post

 Thanks for the replies Darian and Jasmine,

So I now have no content-type specified on my program, on every html I am printing I put print <<"endhtml";
and it worked. Amazingly enough. But I still can't do what I want. I have a search engine and I want it to go to a meta-engine if there are no results in the database for someone's query . So that's why I need to print html (for the results) and location for the redirect. I tried using goto Label; functions but it still won't work because the html print's to the page before It reaches the goto statement. I have the goto statement going to the top of the program to a print "location:address function, I can't move the goto command that takes you to the top of the program above the html that is printed because than my if($noresults) won't work. So you can see that I am trapped. Is there a way to invoke another script that will redirect you from there? Like an exec(). I have seen them but I don't know how to do this myself. Do any of you?


Or what about parsing, how can I go to the meta engine and bring the results to me?


Thank you so very very much,

perlkid


[This message has been edited by perlkid (edited 02-26-2000).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives