Jump to content

[SOLVED] Checking if info is posted


ninjablade15

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.