As a phper, we are in the development and learning of PHP process, it is inevitable to often accept processing form data, however, when processing the form there will always be a problem, bothering everyone, refresh the page repeatedly submitted questions. How do I prevent pages from being refreshed repeatedly?
In fact, in the PHP learning we will have a lot of methods, such as the simplest, we can adopt, after the successful submission of the method of jump. But doing this, sometimes, there will be a lot of bottlenecks, for example, if our page has a lot of content to be loaded, especially with a lot of background dealing with, so if the jump to reload the page, it may cause pressure on the server. Here we can use another method to prevent refreshing the page to repeat the submission, so that everyone better learn PHP.
We can use session to solve. We first create a session, and assign a value, the first submission after the change of the session's value, when the second time this content submission, if not our assignment, it is not processing the data passed over.
Such as:
<?php
Session_Start ();
$_session[' num '] = 0;
if (Isset ($_post[' action '] && $_post[' action ']== ' submit ')) {
if ($_session[' num '] = = 0) {
Echo ' <a href= '. $_server[' php_self '. ' > ' Please try again </a>; '
$_session[' num '] = 1;
}else{
Echo ' You have already submitted, please do not repeat ';
}
}
?>
The front page is not given, I believe we all know how to write in front. In fact, such as to prevent the page to refresh the repeated submission of the method, there are many, in the future of the exchange of PHP learning, will be more enumerated.