PHP $_GET and $_POST undefined problem

后端 未结 5 715
广开言路
广开言路 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 15:00

    Since there is no index $_GET['confirm'], PHP throws a notice that you are looking at an undefined index. The notice is being displayed because the new server has the E_NOTICE flag set in error_reporting somewhere, either in php.ini or in some config file or bootstrap that is run on pageloads.

    From the php manual, E_NOTICE: "Run-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script."

    You can either try turning off the notices if you aren't worried about them, or use them to track down places where there may be problems.

    For the code you posted, an easy fix would be to change the conditional to

    if(isset($_GET['confirm']) && )
    

    That way PHP bails out of evaluating the conditional if there is no 'confirm' index.

提交回复
热议问题