isset function doesn't work on my form and form is nod getting submitted

php isset vs empty
isset function in php form submit
isset in javascript
empty php
not isset in php
isset() function with example
isset in laravel
cannot use isset() on the result of an expression

I am submitting form to page and checking if submit button value InsertMe isset but non of the code inside is executed

<?php 
if (isset($_POST['InsertMe'])){

//code to execute
echo "Test";

}
?>

and insert buttons looks like that

<input style="float:right;" name="InsertMe" id="InsertMe" type="submit" class="rectangular-button" value="Add User" />
if (!isset($_POST['InsertMe']) || empty($_POST['InsertMe'])) {

// error message here

} else {

// What you want to do if not empty and is set.

}

This code will check if the variables is set and if if it's empty.

"||" is the PHP operator to check or. So in this case it's checking if it's set OR empty.

isset - Manual, The isset () function is used to check whether a variable is set or not. the structure of the dynamic query itself cannot be parametrized and  The isset() function checks whether a variable is set, which means that it has to be declared and is not NULL. This function returns true if the variable exists and is not NULL, otherwise it returns false. Note: If multiple variables are supplied, then this function will return true only if all of the variables are set.

Make sure you have the form tag set to post.

<form method="post">

PHP isset() function, The isset() function is an inbuilt function in PHP which checks whether a has null value, if it does, isset() returns false, it returns true in all other possible cases. isset() will return FALSE when checking a variable that has been assigned to NULL. Also note that a null character ("\0") is not equivalent to the PHP NULL constant. If multiple parameters are supplied then isset() will return TRUE only if all of the parameters are considered set. Evaluation goes from left to right and stops as soon as an unset variable is encountered.

you are selecting Id I think we should be use name tag parameters in isset()

Why to check both isset() and !empty() function in PHP , The isset() function checks whether a variable is set, which means that it has to be declared and is not NULL. This function returns true if the variable exists and  The isset () function is used to check whether a variable is set or not. If a variable is already unset with unset () function, it will no longer be set. The isset () function return false if testing variable contains a NULL value.

What does the isset () function do in PHP?, According to a manual: If multiple parameters are supplied then isset() will return TRUE only if all of the parameters are set. So, if $b is not set,  PHP isset() PHP isset() function is used to check if a variable exists in the code or not. It means we check the value of any particular variable. We use the isset function to check if any variable that is passed, exists in the code and also possess some value. If a variable have some value then it is said to be set and if it doesn't have any value stored in it that is contains NULL then it is said to be unset.

Isset() function doesn't work properly, PHP isset guide: learn how to use PHP to check if variable exists and is that empty() can take expressions as arguments, while isset() cannot. The isset () function checks whether a variable is set, which means that it has to be declared and is not NULL. This function returns true if the variable exists and is not NULL, otherwise it returns false. Note: If multiple variables are supplied, then this function will return true only if all of the variables are set.

Learn About PHP isset Function: PHP isset vs empty Explained, Return Values. The isset() function returns a boolean value: It may be either true or false. If the variable exists and does  isset() Function The isset() function is an inbuilt function in PHP which checks whether a variable is set and is not NULL. This function also checks if a declared variable, array or array key has null value, if it does, isset() returns false, it returns true in all other possible cases.

Comments
  • Is your form using POST?
  • Can you try <?php print_r($_POST); ?>?
  • Add a var_dump($_POST) at the top of the file
  • not sure if it's related but why do you have the type="submit" on the input? did you try to update your form in order to have one input named InsertMe carrying your value, and a button/anchor submitting the form, having the Type=submit ?
  • can you post the code for form
  • @Script47 - you're missing a closing bracket after the isset function call.
  • name and id have the same name, why do you think that should be wrong?