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

PHP prevent external form submission

WBOY
WBOYOriginal
2016-07-25 08:42:13971browse

[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


Statement:
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