Home > Backend Development > PHP Tutorial > PHP prevent external form submission

PHP prevent external form submission

WBOY
Release: 2016-07-25 08:42:13
Original
997 people have browsed it

[PHP] code

  1. $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL;
  2. $host = $_SERVER['HTTP_HOST'];
  3. echo 'Submitted address:'. $referer;
  4. echo '
    ';
  5. echo 'This site's domain name: '.$host;
  6. echo '
    ';
  7. echo substr($referer,7,strlen($host));
  8. if(substr($referer,7,strlen($host)) != $host){
  9. echo 'illegal operation';
  10. }else{
  11. echo 'normal operation';
  12. }
Copy code
PHP


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template