cgi programming. what is it? cgi –common gateway interface standard way to pass information back...
TRANSCRIPT
![Page 1: CGI Programming. What is it? CGI –Common Gateway Interface Standard way to pass information back to the Web Server –GET Query String –POST Standard Input](https://reader035.vdocument.in/reader035/viewer/2022071808/56649eef5503460f94bff2de/html5/thumbnails/1.jpg)
CGI Programming
![Page 2: CGI Programming. What is it? CGI –Common Gateway Interface Standard way to pass information back to the Web Server –GET Query String –POST Standard Input](https://reader035.vdocument.in/reader035/viewer/2022071808/56649eef5503460f94bff2de/html5/thumbnails/2.jpg)
What is it?
• CGI– Common Gateway Interface
• Standard way to pass information back to the Web Server– GET
• Query String
– POST• Standard Input
![Page 3: CGI Programming. What is it? CGI –Common Gateway Interface Standard way to pass information back to the Web Server –GET Query String –POST Standard Input](https://reader035.vdocument.in/reader035/viewer/2022071808/56649eef5503460f94bff2de/html5/thumbnails/3.jpg)
What is CGI?
• CGI is platform independent
• CGI is language independent
• Perl is the most popular development language
![Page 4: CGI Programming. What is it? CGI –Common Gateway Interface Standard way to pass information back to the Web Server –GET Query String –POST Standard Input](https://reader035.vdocument.in/reader035/viewer/2022071808/56649eef5503460f94bff2de/html5/thumbnails/4.jpg)
CGI Environment
• CGI uses a subset of the OS environment for the application
• Can access native applications on server
• Runs as the server userid (normally)
• See showenv.pl
![Page 5: CGI Programming. What is it? CGI –Common Gateway Interface Standard way to pass information back to the Web Server –GET Query String –POST Standard Input](https://reader035.vdocument.in/reader035/viewer/2022071808/56649eef5503460f94bff2de/html5/thumbnails/5.jpg)
CGI/HTML
• Data is passed to a CGI program from a HTML file with the Form tag– Method = GET– Method = POST
![Page 6: CGI Programming. What is it? CGI –Common Gateway Interface Standard way to pass information back to the Web Server –GET Query String –POST Standard Input](https://reader035.vdocument.in/reader035/viewer/2022071808/56649eef5503460f94bff2de/html5/thumbnails/6.jpg)
Parsing Data
• If request is passed via GET, use QUERY_STRING environmental variable
• If request is passed via POST, you must read in the data from STDIN (the CONTENT_LENGTH environmental variable specifies how much data to read)
![Page 7: CGI Programming. What is it? CGI –Common Gateway Interface Standard way to pass information back to the Web Server –GET Query String –POST Standard Input](https://reader035.vdocument.in/reader035/viewer/2022071808/56649eef5503460f94bff2de/html5/thumbnails/7.jpg)
Parse Some Data
• See advance.htm
• See simple_parse.pl
• See sample_cgipm.pl
![Page 8: CGI Programming. What is it? CGI –Common Gateway Interface Standard way to pass information back to the Web Server –GET Query String –POST Standard Input](https://reader035.vdocument.in/reader035/viewer/2022071808/56649eef5503460f94bff2de/html5/thumbnails/8.jpg)
Form Verification
• Need to verify data before processing
• Bad data can be a security risk
• Assume all data is initially bad
• see verify.pl
• (In real life also use JavaScript )
![Page 9: CGI Programming. What is it? CGI –Common Gateway Interface Standard way to pass information back to the Web Server –GET Query String –POST Standard Input](https://reader035.vdocument.in/reader035/viewer/2022071808/56649eef5503460f94bff2de/html5/thumbnails/9.jpg)
Cookies: State Management
• HTTP is stateless
• Cookies are the standard method for state management
• Can use hidden fields, mangled URLs, etc
• see cookie.htm
• see cookie.pl
• Cookies are not evil! :)
![Page 10: CGI Programming. What is it? CGI –Common Gateway Interface Standard way to pass information back to the Web Server –GET Query String –POST Standard Input](https://reader035.vdocument.in/reader035/viewer/2022071808/56649eef5503460f94bff2de/html5/thumbnails/10.jpg)