CGI - perldoc. perl. CGINAMECGI - Handle Common Gateway Interface requests and responses. SYNOPSISuse. CGI; my$q = CGI- > new; # Process an HTTP request@values = $q- > param('form. Some HTML. generation utilities are included as well. Upload multiple files with a single file element Published July 13th, 2005. STOP PRESS: There is now a new version here, based on Mootools. Writing cfclient code in ColdFusion builder. The CFML editor in ColdFusion Builder 3 provides you all the support for writing cfclient code. It provides you with code. TreeGrid has live examples and tutorials on how to display and edit your data in a JavaScript table, grid, tree view, tree grid or gantt chart on a HTML page. CGI. pm performs very well in a vanilla CGI. If the parameter is multivalued (e. You can either. incorporate the error text into an HTML page, or use it as the value. HTTP status: my$error = $q- > cgi. Be ready. for this! USING THE FUNCTION- ORIENTED INTERFACETo use the function- oriented interface, you must specify which CGI. If they find a like- named parameter, they. Sometimes this isn't what you want. With this. option turned off, you can still add tab indexes manually by passing a. Use this with. care, as it will interfere with the processing of binary uploads. It. is better to manually select which fields are expected to return utf- 8. Encode; my$arg = decodeutf. This makes CGI. pm produce a header appropriate for an NPH (no. Ordinarily it spools the uploaded. On Unix. systems, the - private. Note that RFC 2. 61. The last example shows the named argument style for passing arguments. CGI methods using named parameters. For example: printheader( - ingredients=>. When multi- line headers. CGI. pm will always output them back as a single line, according to the. RFC 2. 61. 6: the newlines will be removed, while the white space remains. GENERATING A REDIRECTION HEADERprint$q- > redirect('http: //somewhere. Sometimes you don't want to produce a document yourself, but simply. URL based on the. The redirect() method redirects the browser to a different URL. However, most HTTP headers, including those generated by. The - nph parameter, if set to a true value, will issue the correct. NPH (no- parse- header) script. For example: - dtd=> '- //W3. C//DTD HTML 4. 0. Transitional//EN')Alternatively, it can take public and system DTD identifiers as an array: dtd=>. Otherwise it. will be replaced by the default DTD. If the public DTD contains 'XHTML', CGI. XML. The - declare. The sole. purpose of this declaration is to declare the character set. In the absence of - declare. To use these. attributes pass a HASH reference in the - script parameter containing one or. For example: script. Produce the full URL, exactly as if called without any arguments. Set. - rewrite=> 1 (default) to return URLs that match what the user sent. URI). Set - rewrite=> 0 to return URLs that match. URL after mod. Example: print$q- > blockquote(. This means you. should Encode: :decode data received from . If your source code UTF- 8 encoded and. See perlunitut, perlunifaq and perlunicode for more. Perl handles the difference between bytes and characters. The automatic escaping does not apply to other shortcuts, such as. This is yuck, but. Calling escape. HTML(). HTML. A Lurking Trap! Some of the form- element generating methods return. After submission this name can be used to. The initial value of the field which will be returned to the script. Others, such as popup menus, take a. The two arguments are synonyms.- tabindex. A numeric value that sets the order in which the form element receives. Elements with lower values. A string identifier that can be used to identify this element to. Java. Script and DHTML.- override. A boolean, which, if true, forces the element to take on the value. Change, - on. Focus, - on. Blur, - on. Mouse. Over, - on. Mouse. Out, - on. Select. These are used to assign Java. Script event handlers. See the. Java. Scripting section for more details. Other common arguments are described in the next section. In addition. to these, all attributes described in the HTML specifications are. CREATING A TEXT FIELDprinttextfield(- name=> 'field. To. retrieve this information, call upload. Info(). After you are finished with the. CGI. pm unlinks (deletes) the temporary file. If you need to you. You can access the temp file for a file. File. Name() method: $filename = $query- > param('uploaded. On some operating systems (such as Windows NT), you. You can use this feature to completely turn off. This is much like the UPLOAD. If you. set this to a FALSE value (default true) then $q- > param('uploaded. The. value it returns has a dual nature as both a file name and a lightweight. This dual nature is problematic if you following the recommended. Perl will complain when you try. This generally works well, but will have trouble. IO: :Handle. So that brings us to current recommendation given above. It's a big win for compatibility for. IO: :Handle the first time you call it. CREATING A POPUP MENUprintpopup. Pass an array reference to select multiple defaults. The optional fourth parameter (- labels) is provided for people who. It's. a pointer to a hash relating menu values to another. When the form is processed, the selected value of the popup menu can. It's. a pointer to a hash relating menu values to another. CREATING A SCROLLING LISTprintscrolling. It's. a pointer to a hash relating menu values to another. When this form is processed, all selected list items will be returned as. It's a pointer to. The optional - tabindex argument can be used to control the order in which. If not specified, the first item will be the. It's a pointer to. The optional - labelattributes argument will contain attributes. When the form is processed, the selected radio button can. The. name will also be used as the user- visible label. You can use - label as an alias for - value. This example uses the object- oriented. CGI; $query = CGI- > new; $riddle = $query- > cookie('riddle. Create a < Frameset> document. After writing out the HTTP header, instead of creating a standard. HTML document using the start. Specify the destination for the document in the HTTP header. You may provide a - target parameter to the header() method: printheader(- target=> 'Results. Window'); This will tell the browser to load the output of your script into the. Specify the destination for the document in the < form> tag. You can specify the frame to load in the FORM tag itself. Events include such. When an event occurs that involves an element that has. Java. Script code gets. The elements that can register event handlers include the < BODY> of an. HTML document, hypertext links, all the various elements of a fill- out. There are a large number of events, and. Here is a. partial list: on. Load. The browser is loading the current document. Valid in: + The HTML < BODY> section only. Unload. The browser is closing the current page or frame. Valid for: + The HTML < BODY> section only. Submit. The user has pressed the submit button of a form. This event happens. Valid for: + Buttons(includingsubmit,reset, and imagebuttons) + Checkboxes + Radiobuttonson. Change. The user has changed the contents of a field. Valid for: + Textfields + Textareas + Passwordfields + Filefields + Popup. Menus + Scrollinglistson. Focus. The user has selected a field to work with. Valid for: + Textfields + Textareas + Passwordfields + Filefields + Popup. Menus + Scrollinglistson. Blur. The user has deselected a field (gone to work somewhere else). For example, to have your validate. Age() Java. Script code. If you. give this method a single argument corresponding to a MIME type, as in. Accept('text/html'), it will return a floating point value. On the final iteration, it ends the. In other. cases, you can use the shell limit or ulimit. CGI resource usage. CGI. pm also has some simple built- in protections against denial of. On a script- by- script basis. Set the variable at the top of the script, right after the . Globally for all scripts. Open up CGI. pm, find the definitions for $POST. You'llhavetorollyourown if youreallyneedit. AUTHOR INFORMATIONThe CGI. Lincoln D. It is. GPL and the Artistic License 2. It is currently. maintained by Mark Stosberg with help from many contributors. Address bug reports and comments to: https: //rt. Public/Dist/Display. Queue=CGI. pm. When sending bug reports, please provide the version of CGI. Perl, the name and version of your Web server, and the name and version of the. Hendricks (kbhend@dogwood. Stephen Dahmen (joyfire@inxpress. Ed Jordan (ed@fidalgo. David Alan Pisoni (david@cnation. Doug Mac. Eachern (dougm@opengroup. Robin Houston (robin@oneworld. A COMPLETE EXAMPLE OF A SIMPLE FORM- BASED SCRIPT #!/usr/local/bin/perl use CGI ': standard'; print header; print start. Stein< /address> < br> < a href=.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |