Lesson 17th PHP language and database-2011.11.6
POST facilitates the transmission of private information and binary information, such as examples. Get can copy the link to access webpages in the same status. For example, you can use linux cron to regularly retrieve data from the web. When user information is submitted on the webpage, data will be checked. If an error occurs, you may want to stay on the same webpage, display the information you have entered, and prompt for an error. You can execute the PHP code at the beginning of the webpage:
if($_POST["action"]){ ... ...}
PHP language, with mail function, can define an array, for example: $ DORMS = array ("xx ",....); you can use foreach ($ DORMS as $ dorm) to obtain data ).
Databases, especially open-source MYSQL databases, are widely used by facebook. In PHP, related functions are: mysql_connect ("domain", "usr", "pw"); mysql_select_db ("mydb"); mysql_query ($ SQL ); hacker may enter certain characters or strings on the page, such as ", \" and DELETE. If these characters are passed as parameters, such as mysql_query (), there is a security risk, to avoid this problem, execute mysql_real_escape_string () after connecting to the database ().
Next we will introduce some usage of the SQL language.
18th Webpage Design -2011.11.9
In PHP, $ _ SESSION is a global variable, for example, $ _ SESSION ["uid"] = 123; is used to store the user's ID. After this HTTP request is disconnected, cookie storage allows you to perform the next step as a logged-on user.
For PHP, If you can use. As the + in java, the append string function is provided. PHP is an interpreted language and does not require a compiler. It is parsed by an interpreter. For example, we can provide an executed PHP script in Linux. The first act is:
#! /Usr/bin/php
Indicates that the interpreter is/usr/bin/php, or $ php <file_name> is used for processing at runtime. PHP is a server processing method. JavaScript is executed in a browser and provides dynamic interaction effects. However, we should also note how to run scripts in a browser and modify the scripts. Therefore, security-related processing should be carried out on the server. UX-related processing does not matter, in the browser, the speed is fast and the user experience is good. Google provides APIs for a series of charts. HTML5 is a hot topic: Standard and open. You do not need to download and run the plug-in java or flash.
<Script type = "text/javascript"> // JS does not need to define the type function mycheck () {if (document. forms. registration. email. value = ") {// DOM: Document Object Model, which can be used for hierarchical tree-like parsing of XML scripts. return false;} else if (... ... ){... ...}... ... } </Script> <form action = "sdfsd. php "name =" registration "method =" get "onsubsce =" return mycheck (); "> .... </form>
In Java Script, DOM (Document Object Model) can be used to organize all spaces in HTML. Ajax, that is, Asynchronous JavaScriptXML, can send requests asynchronously to the server (XMLHttpRequest, after receiving XML Data, trigger XMLHttpRequestCallBack processing), add the new content to the page, that is, you do not need to refresh the whole page, but only partially update the page.
Related Links: My articles related to programming ideas