1. PHP and forms
1.POST method to send data manually:
Some differences between the two:
GET:
1. Gather information and send it as part of the URL
2. The number of transmissions is limited
3. Public transmission, such as password information will be exposed
4. The created form can be added as a bookmark.
POST:
1. The transmitted information cannot be seen by users
Usage example:
html file: ws.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>test</title> <body> </body> </html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>test</title> </head> <body> 
<?php ini_set('display_errors', 1); error_reporting(E_ALL|E_STRICT); http://blog.csdn.net/u014761420/article/details/<strong><span style="color:#ff0000;">$title=$_POST['title']; $name =$_POST['name'];</span></strong> print "<p> hello <span style="color:#ff0000;">$title $name</span>"; ?> </body> </html>
Result: hello Mr myname
2.GET transfer data
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>test</title> <body> <ul> <li><span style="color:#ff0000;">"handle.php?name=Charles</span></strong>">Charles</li> </ul> </body> </html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>test</title> </head> <body> 
<?php ini_set('display_errors', 1); error_reporting(E_ALL|E_STRICT); http://blog.csdn.net/u014761420/article/details/<strong><span style="color:#ff0000;">$name=$_GET['name']; print "<p> hello $name";</span></strong> ?>
</body> </html>
2. Related function learning
1. Format values:
round (the number to be formatted, retaining the number of decimal points);
eg: $test=5.555555555; round(test, 2); // 5.55
number_format(number, number of decimal points, symbol to replace decimal point, thousands separator)
eg: number_format("10000000", 2 ,"," ,".");// 10.000.000,00
2. Random function rand()
eg:rand(0, 100);//Generate a random number from 0-100