0

I am transitioning a bunch of old sites php5.6 sites to php8 and I'm trying to grasp my head around some of these new requirements.

In php5.6, I could submit a form and then check the value on the next page, but now I'm getting an error saying undefined array key.

if($_REQUEST['action']=='submitform'){

// do this after form is submitted
}

<form><input type="hidden" name="action" value="submitform"><input type="submit"></form>

But now in PHP8, I get a message Undefined array key "action" in...

I know it's because I haven't submitted the form yet, so 'action' isn't set. What's the new way to just check to see if a value is set to something without giving the error that the variable I'm checking isn't even set yet??

This is how I fixed it, but is there a better way?

 if(!empty($_REQUEST['action']) && $_REQUEST['action']=='submitform'){
Clint Decker
  • 121
  • 1
  • 3

0 Answers0