PHP $_GET and $_POST undefined problem

后端 未结 5 704
广开言路
广开言路 2020-12-06 14:22

I\'m new to PHP so I apologize if this is a simple problem...

I am moving a PHP site from one server to another. The new server is IIS 7.0, PHP 5.2.1, with short op

5条回答
  •  一生所求
    2020-12-06 14:56

    The new server has error_reporting set to E_ALL. What you're seeing is a notice, not an error. Try:

    error_reporting(E_ALL ^ E_NOTICE)
    

    With error reporting set to E_ALL, accessing a member of an array which is not set generates an error. If you don't wish to lower your error reporting level, before checking $_GET['var'], change your code to:

    if(isset($_GET['confirm']) && ($_GET['confirm'] == 13 || $_GET['confirm'] == 14 || $_GET['confirm'] == 15 || $_GET['confirm'] == 16)) {
    

    by adding the call to isset() before you actually access $_GET['confirm'], you will verify that you're not accessing an array member which is not set. ($_GET['confirm'] will only be set if the URL ends in ?confirm=... or ?something...&confirm=...)

提交回复
热议问题