Open Course Study Notes-[Harvard] Computer Science CS50 (8)

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.