124Part IPHP: The BasicsBut even with this solution, (Crystaltech web hosting)

124Part IPHP: The BasicsBut even with this solution, you still have to tend part of your garden by hand: making sureeach includefile is properly formatted in HTML, adding a new link to the navbar each time youadd a new page to the site, and other such chores. Following the general rule to separate formand content as much as is feasible, you might choose to go to another level of abstraction witha database. In that case, a URL such as http://localhost/topic.php?topicID=2wouldpoint to a PHP template that makes database calls. (Using a number variable rather than a word makes for faster database interaction.) This system could also automatically add a link tothe navbar whenever you added new topics to the database, so it could produce Web pagesentirely without ongoing human intervention (all right, maybe entirelyis an exaggeration butwith significantly fewer person-hours of grunt labor). POST ArgumentsPOSTis the preferred method of form submission today, particularly in nonidempotentusages(those that will result in permanent changes), such as adding information to a database. Theform data set is included in the body of the form when it is forwarded to the processing agent(in this case, PHP). No visible change to the URL will result according to the different datasubmitted. The POSTmethod has these advantages: .It is more secure than GETbecause user-entered information is never visible in the URLquery string, in the server logs, or (if precautions, such as always using the passwordHTML input type for passwords, are taken) onscreen. .There is a much larger limit on the amount of data that can be passed (a couple of kilo- bytes rather than a couple of hundred characters). POSThas these disadvantages: .The results at a given moment cannot be bookmarked. .The results should be expired by the browser, so that an error will result if the useremploys the Back button to revisit the page. .This method can be incompatible with certain firewall setups, which strip the formdata as a security measure. Get and Post bothDid you know that with PHP you can use both GETand POSTvariables on the same page? Youmight want to do this for a dynamically generated form, for example. But what if you (deliberately or otherwise) use the same variable name in both the GETand thePOSTvariable sets? PHP keeps all ENVIRONMENT, GET, POST, COOKIE, and SERVERvariables in the$GLOBALSarray if you have set the register_globalsconfiguration directive to on in yourphp.inifile. If there is a conflict, it is resolved by overwriting the variable values in the order youset, using the variables_orderoption in php.ini. Later trumps earlier, so if you use thedefault EGPCS value, cookies will triumph over POSTs that will themselves obliterate GETs. You can control the order of overwriting by simply changing the order of the letters on the appro- priate line of this file, or even better, turning register_globalsoff and using the new PHPsuperglobal arrays instead. See the section on superglobals later in this chapter.
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

Leave a Reply