How to make the front page of the page and
Background CGI pages remain interactive for a long time. Here are two I make in practice
The method used.
Method One: Interact with cookies. Altogether there are three files,
Some of the post links submitted by robots in recent comments are spam comments. In order to reduce this unnecessary link content appears, actually can use PHP to delete form Post submitted HTML tags, so the machine submitted information will not
Example one, each time we open the Submit page to generate a token and then save in session, when the form is submitted we will determine whether the current token value and session is consistent, if it is a normal submission otherwise is invalid
example, use the Strip_tags () function to filter all HTML
The code is as follows
Copy Code
$str = ' href";echo Htmlspecialchars ($STR);echo Strip_tags ($STR);Output results areHref
One problem with the above
?/*************************DescriptionDetermines whether the passed variable contains illegal characterssuch as $_post, $_getFunction:Anti-injection*************************/Illegal characters to filter
The code is as follows
Copy
At first, there was a php.ini to see if the GD library was turned on,Next, we will consider each detail of the image generation step.Send a generated image to the browserCreate_image ();Exit ();
function Create_image (){Let ' s generate a totally
/**lock_thisfile: Get exclusive lock* @param $tmpFileStr file name used as a shared lock file (you can name one)* @param $locktype lock type, the default is False (Non-blocking, that is, if the lock fails to return false directly), set to True will
Generates random strings that can be used to generate passwords automatically.Characteristics:1. You can specify that the password contains numbers or characters, and the default is blending mode2. Specify the arbitrary password length, the default
The other principle is very simple. It is implemented by using the target attribute and iframe of the form. Open the iframe and try again. If the result is returned, use js to determine whether the parameters returned after the php Tutorial is run
Because I need to update the release date of a batch of data at work, if I want to update the data for 30 days from 20110112 today, we found that the strtotime function and date in the php Tutorial can easily implement the code.The strtotime ()
ajax php Tutorial: users can log on to an instance without any need Enter the user name Userlogin. Php file$ Uid = $ _ post ['uname'];$ Pwd = $ _ post ['upwd '];$ SQL = "select * from tabname where uid = '$ uid' and pwd =' $ pwd '";$ Query =
Session_start (), session_register (), session_unregister (),Session_is_registered (), session_destroy function.Session_start (): Enables the session mechanism and calls it at the very beginning of the program file that requires the
Class upload {/*** Name attribute of the input field of an html form. The default value is 'file'*/Var $ file_field = 'file '; /*** $ _ Files array*/Var $ file_array; /*** Save path. The default value is the current path.*/Var $ save_path = '';
SyntaxTempnam (dir, prefix)*/Function dir_wriable ($ dir) // customize function extension to create a temporary file{$ Test = tempnam ("$ dir", "test_file"); // create a temporary fileIf ($ fp = @ fopen ($ test, "w") // if the file is successfully
Use the iconv function:Iconv ("UTF-8", "gb2312", "abc Sunshine 123 ");It is said that this is better, you can ignore the conversion error!Iconv ("UTF-8", "gb2312 // ignore", "abc Sunshine 123 ");For the usage of mb_convert_encoding, refer to the
If this problem occurs, the variable is undefined. We only need to add a verification code, as shown in figure$ A = isset ($ _ get ['A'])? $ _ Get ['A']: 'variable undefined ';In this way, undefined variable and undefined index are not displayed for
Incorrect php date reading time$ DateTime = date ("Y-m-d H: I: s ");Echo $ DateTime;Why is the printed date inconsistent with the system time on my server. I tested it locally.Configure php. iniYou can also set it to GMT in php. ini:Open php. ini to
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