View Full Version : New to CGI...
nathan99
07-14-2005, 07:30 AM
Hey guys,
im new to CGI and have no idea where to start, any ideas? and can u send emails via cgi, if so how :)
Aradon
07-14-2005, 01:52 PM
Just a thought:
http://www.google.com/search?hl=en&q=CGI+Tutorial
nkrgupta
07-14-2005, 02:08 PM
http://homepages.paradise.net.nz/milhous/cgi.htm
Also you can visit sites like perl.com, cpan.org, beside online books on cgi from o'reilly, wiley etc.
Jeff Mott
07-14-2005, 06:49 PM
http://homepages.paradise.net.nz/milhous/cgi.htmThis site teachs a lot of practices that are considered bad Perl programming. I personally wouldn't recommend it.
There is a very good book that is free and online that is intented for beginners but still has a good level of depth.
http://learn.perl.org/library/beginning_perl/
After that I'd recommend Programming Perl, which is authored by Perl's creator, Larry Wall. (Much of the text of this book is the same found in the Perl documentation.)
http://www.unix.org.ua/orelly/perl/prog3/index.htm
And finally, the Perl documentation itself. There are many sites that provide mirrors of the Perl docs. One of the nicer ones I've found is at...
http://perldoc.perl.org/
nathan99
07-15-2005, 07:12 AM
i want cgi, not perl
FishMonger
07-15-2005, 07:40 AM
i want cgi, not perl
If you don't want to use Perl, what language do you want to use? CGI scripts can be written in a number of languages. Maybe a better place to start is to ask "what is CGI", then you will be able to better understand the answers that are given.
http://www.google.com/search?hl=en&lr=&oi=defmore&q=define:CGI
http://www.w3.org/CGI/
Here's the doc for the CGI module and one of the available Perl modules for sending emails.
http://search.cpan.org/~lds/CGI.pm-3.10/CGI.pm
http://search.cpan.org/~yves/MIME-Lite-3.01/lib/MIME/Lite.pm
nathan99
07-15-2005, 03:39 PM
ok i got to the realisation that its perl my server allows to be cripted online, BUT it wont work i have
#!usr/local/bin/perl
#
print "hello";
Help! :o
Aradon
07-15-2005, 05:17 PM
I'm not sure if you're expecting a webpage out of that but all that will do is print to standard out.
Are you running it by doig "perl nameoffile" or are you trying to access it through a webpage?
Let's go over quickly the basics of what your script is doing
1 #!/usr/local/bin/perl
2 #
3 print "hello";
1 - This first line points to the unix perl binaries that are installed in the server you are running the script. This can range from /usr/bin to /usr/local/bin/ but it has to point to the binaries for this to work You can include this in a windows perl script as well however it will just be ignored.
2 - Just a comment and so it will be ignored
3 - You are telling the script to print 'hello' to standard out. For one thing, this line will appear on the same line as the command prompt that will show back up. so it will look like this:
> perl hello_world.pl
hello>
To change this you have to use what's called an escape character. This will allow you to create a new line.
print "hello\n"; will produce
> perl hello_world.pl
hello
>
So..let me know if that helps. If you are doing it with webpages then that's a different monster all together ;)
Aradon
07-15-2005, 05:21 PM
Here is a really SIMPLE example of what you can do with cgi:
#!/usr/local/gnu/bin/perl --
# first cgi program
# reply.pl itec 225
# returns a greeting to a user
print "Content-type: text/html \n\n",
"<html> <head> \n",
"<title> reply.pl example </title>",
"</head> \n", "<body> \n",
"<h1>Greetings from your Web server!",
"</h1> \n </body> </html> \n";
To make this look better it would be better to do this:
#!/usr/local/gnu/bin/perl --
# first cgi program
# reply.pl itec 225
# returns a greeting to a user
use CGI qw(:standard);
print header();
print start_html("reply.pl example");
print "<h1>Greetings from your Web server!",
"</h1>";
print end_html;
nathan99
07-16-2005, 01:23 AM
hey, im getting this:)
umm but if i mixed the 2 together would it affect my code?
like i have the fisrt part of the second code, but i can understand the second ones layout easier..?
nathan99
07-16-2005, 03:50 AM
how would u make is send a email also.?
netroact
07-16-2005, 07:43 AM
The first code uses manual html web page code for the output to the web page. The second code just lets the cgi module format the html for the web page with the exception of the opening heading tag <h1>, and closing heading tag </h1>. You want to use the second code.
Email is a totally different puppy. We need a few more specifics. Email from a web page? Are you the sender or the recipient? Is it a contact form? I think maybe Jeff is the resident expert on Perl sendmail. There are security issues involved. :eek:
nathan99
07-17-2005, 04:23 AM
just, you(the visitor) fill a form, with your information & sends...
Yeah, here are my favorite CGI resouce links :
http://www.cgi101.com/
http://www.cgiconnection.com/
http://www.cgispy.com/
http://www.awsd.com/scripts
http://www.extropia.com/tutorials.html
http://www.cgi-resource.com/
http://www.golux.com/coar/cgi/
http://www.thecgisite.com/
http://hoohoo.ncsa.uiuc.edu/cgi/
You can also add your favarite CGI- Resources for my list (http://icebergz.flashband.net/src/src.htm) :)
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.