Home > Software design >  Laravel - Variable check after form submit
Laravel - Variable check after form submit

Time:01-31

is it possible when submitting a form that redirects me with a variable to check if that variable is null? Because when i have if($variable === null) in my code and i dont pass the mentioned variable when loading the page it will result in error that $variable is not defined

CodePudding user response:

you need to define the variable before put it in if condition

not in the if

update:

use this in return : return view('name_page')->with('variable',$variable);

CodePudding user response:

the exception told you that variable doesn't exist on memory so you to check if it exists not in it's value for that you have change your if condition from

if($variable === null) to be if(isset($variable))

  •  Tags:  
  • Related