cgi
Re:cgi
Well to print html in perl you would do this:
as for getting info from the browser there are 2 main info types you need to collect, GET and POST data.
POST data is sent by clicking on a button in the html page.
GET is a variable in the url of your browser.
And you can't make it in C. cgi programs are text documents that are run by the perl interpreter. So you can use notepad, or some text editor or, a perl editor to make your perl code.
Also you need to be aware that the first line of your main perl script MUST contain the proper shebang line. The shebang line is the path to your perl interpreter on your webserver.
Anyway, if you need some help with this just ask.
Code: Select all
print "HTML HERE/TEXT HERE";
POST data is sent by clicking on a button in the html page.
GET is a variable in the url of your browser.
And you can't make it in C. cgi programs are text documents that are run by the perl interpreter. So you can use notepad, or some text editor or, a perl editor to make your perl code.
Also you need to be aware that the first line of your main perl script MUST contain the proper shebang line. The shebang line is the path to your perl interpreter on your webserver.
Anyway, if you need some help with this just ask.
Re:cgi
Here is some code to get the GET data from the url:
Now for instance, if somebody typed index.cgi?action=test
Then in your script, $action would be set to equal "test".
Understand how that works? And you can seperate multiple variables in the url by putting a & or a ; between them. Like this:
index.cgi?action=test;name=Chris
or
index.cgi?action=test&name=Chris
This will make it so $action is set to "test" and $name is set to "Chris".
Anyway does this help you some?
Code: Select all
@query_strings = split('[;&]',$QUERY_STRING);
foreach $tmp (@query_strings) {
???($key,$value) = split(/=/,$tmp);
???$$key = $value;
}
Then in your script, $action would be set to equal "test".
Understand how that works? And you can seperate multiple variables in the url by putting a & or a ; between them. Like this:
index.cgi?action=test;name=Chris
or
index.cgi?action=test&name=Chris
This will make it so $action is set to "test" and $name is set to "Chris".
Anyway does this help you some?
Re:cgi
I mean an environment variable. All mainstream operating systems have them. If you're running Windows, bring up a command prompt and type SET.elias wrote:what do you mean by enviromental variables?
I'm not sure what you're talking about here.cant i just open up an input stream with the internet connection, and since the browsers on the other side, wat i read in will be what is sends. cant i do that?
A CGI program works as follows:
- The HTTP server gets a request for a file that it knows is executable (the CGI program)
- The server sets up environment variables for things like the original HTTP request string and the headers that the browser sends
- The server starts the CGI program and redirects its standard output stream (stdout in, std::cout in C++) to the connection it has with the user's browser
- The CGI program does what it needs to and emits headers and HTML (or headers and some other file, depending on the Content-Type header it emits)
Re:cgi
well then i guess its not a cgi. i guess its just a server. so my server only has to set up an input stream on the port, and itll read whatever the browser sends? i think i understand. but this also means that the prog will generate teh html to spit out, depending on what it reads in. thats not a prob. but another question, how do i set it up, so that tht html gives a link, that when clicked, goes into a message board. will i have to create a pseudo message board through html? just one that accepts posts, and adds them?
Re:cgi
It sounds like a CGI program is what you want, unless you feel like writing your own HTTP server from scratch.
I suggest you read the documentation of whatever HTTP server you're using. If you don't run your own HTTP server (e.g. you're using webspace provided by someone else), you need to talk to your provider.
I suggest you read the documentation of whatever HTTP server you're using. If you don't run your own HTTP server (e.g. you're using webspace provided by someone else), you need to talk to your provider.
Re:cgi
i didnt even know i needed to run an HTTP server. im new ot web programming. so through a HTTP server, i can also run a message board, so that from the code my cgi spits out, users can connect to? ie, the cgi sends out a link, so that when a logged in user clicks on it, they will be logged into the message baord?
Re:cgi
Yes that is correct you do need to run it through a HTTP server. And yes you can make it so your code spits out a link to login... although you have to build the login functions and such.
Of course you can always download a cgi message board... although most cgi message boards are flat file and alot of hosts disallow flat file message boards and will drop you from being hosted if you use one.
I do recommend YaBB(flatfile) and IkonBoard(MySQL) those 2 cgi message boards are the best in my opinion.
Of course you can always download a cgi message board... although most cgi message boards are flat file and alot of hosts disallow flat file message boards and will drop you from being hosted if you use one.
I do recommend YaBB(flatfile) and IkonBoard(MySQL) those 2 cgi message boards are the best in my opinion.