Pergunta

I am passing a value through a form submission and then echo'ing the result (echo $_POST["value"];) onto the page in multiple places as a "test."

As I am doing this, I noticed that after my IF statement, the $_POST["value"] stops returning its value and I believe it is returning NULL.

The IF statement checks to see if the $_POST["value"] = NULL

Any reason for this?

Does $_POST only work once (or a limited number of times) before its "used up" or is there some other function that clears this value?

Foi útil?

Solução

This is because you are using = insted of ==

= Sets the variable value.

== Check if it value is equal to another value.

Outras dicas

This is Wrong way of checking NULL values.Use isset or empty instead

issetDetermine if a variable is set and is not NULL

if(isset($_POST["value"])){

} 

OR

emptyDetermine whether a variable is empty

if(empty($_POST["value"])){
//Do what ever 

} 

its $_POST["value"] == NULL not $_POST["value"] = NULL

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top