Posts

The register_globals php.ini Directive Is Disabled

The register_globals php.ini Directive Is Disabled Versions of PHP prior to 4.2 shipped with the php.ini register_globals directive set to 'Yes' by default. This caused submitted parameters ('user' and 'address' in Listing 10.2) to be generated as global variables ($user, $address). This functionality is now disabled by default, and register_globals is set to 'No'. You can reverse this setting yourself by setting register_globals back to 'Yes' in the php.ini file, but use of automatic globals is now actively discouraged because of the potential security risks involved. The superglobal variables $_GET, $_SET, and $_REQUEST are unaffected by the register_globals directive.

Reading Input from the Form

Reading Input from the Form in Listing 10.2 1: 2: "-//W3C//DTD XHTML 1.0 Strict//EN" 3: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4: 5: 6: <a class="docLink" href="#ch10list03">Listing 10.3</a> Reading Input from the Form in <a class="docLink" href="#ch10list02">Listing 10.2</a> 7: 8: 9: 10: 11: print "Welcome ".$_GET['user']." \n\n"; 12: print "Your address is: ".$_GET['address']." "; 13: ?> 14: 15: 16:

Some Common $_SERVER Elements Variable

Some Common $_SERVER Elements Variable $_SERVER['PHP_SELF'] The current script. Suitable for use in links and form element action arguments. /phpbook/source/listing10.1.php $_SERVER['HTTP_USER_AGENT'] The name and version of the client. Mozilla/4.6 –(X11; I;Linux2.2. 6-15apmac ppc) $_SERVER['REMOTE_ADDR'] The IP address of the client. 158.152.55.35 $_SERVER['REQUEST_METHOD'] Whether the request was GET or POST. POST $_SERVER['QUERY_STRING'] For GET requests, the encoded data sent appended to the URL. name=matt&address=unknown $_SERVER['REQUEST_URI'] The full address of the request, including query string. /phpbook/source/listing10.1.php? name=matt $_SERVER['HTTP_REFERER'] The address of the page from which the request was made. http://p24.corrosive.co.uk/ref.html

PHP Superglobal Arrays Array

PHP Superglobal Arrays Array Description $_COOKIE Contains keys and values set as browser cookies $_ENV Contains keys and values set by the script's shell context $_FILES Contains information about uploaded files $_GET Contains keys and values submitted to the script using the HTTP get method $_POST Contains keys and values submitted to the script using the HTTP post method $_REQUEST A combined array containing values from the $_GET, $_POST, and $_COOKIES superglobal arrays $_SERVER Variables made available by the server $GLOBALS Contains all global variables associated with the current script

Working with Forms

How to get and use server variables? How to access information from form fields? How to work with form elements that allow multiple selections? How to create a single document that contains both an HTML form and the PHP code that handles its submission? How to save state with hidden fields? How to redirect the user to a new page? How to build HTML forms that upload files and how to write the PHP code to handle them?

Php and mysql

<html> <head> <title>Untitled Page</title> <script type="text/javascript"> <!-- function BatchValidation() { var validationMessage=""; if(document.form1.txtFName.value=="") { validationMessage+="\n First Name is the required field!"; } if(document.form1.txtLName.value=="") { validationMessage+="\n Last Name is the required field!"; } if(!IsCorrectEmailFormat(document.form1.txtEmail.value)) { validationMessage+="\n Email address is not valid format!"; } if(isNaN(document.form1.txtPhoneNo.value)) { validationMessage+="\n Phone number is number!"; } if(isNaN(document.form1.txtMobileNo.value)) { validationMessage+="\n Mobile number is number!"; } if(validationMessage.length>0) { alert(validationMessage); return false; } else { return true; } } function IsCorrectEmailFormat(strEmail) {

"पाउजु त राम्रो " हेमन्त शर्माको गीत