ninjablade15 Posted June 29, 2007 Share Posted June 29, 2007 Hi I'm new to PHP and I'm trying to test if information has been _posted for use of $_REQUEST, attached is the source file (just got to turn it to .php to test). It works fine but when you first load the page since no information is posted yet I get PHP Notice: Undefined index: year in C:\Inetpub\wwwroot\calender.php on line 12 PHP Notice: Undefined index: day in C:\Inetpub\wwwroot\calender.php on line 13 PHP Notice: Undefined index: month in C:\Inetpub\wwwroot\calender.php on line 14 PHP Notice: Undefined index: year in C:\Inetpub\wwwroot\calender.php on line 48 what would the if() condition be to check if there is information posted for it to $_REQUEST Once I click the submit button it is fine cause I have them _POSTed information. Quote Link to comment Share on other sites More sharing options...
per1os Posted June 29, 2007 Share Posted June 29, 2007 Some code works but doing this would solve the problem: $year = isset($_REQUEST['year'])?$_REQUEST['year']:''; Checks if the variable was set if it was it assigns it to year if not is assings '' to year to avoid a notice error. Quote Link to comment Share on other sites More sharing options...
ninjablade15 Posted June 29, 2007 Author Share Posted June 29, 2007 Awesome thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.