I want to validate a form with php,so I wrote bellow code but as I saw in debug even I set nothing at these fields the if statement does not work!
What is wrong?
If your variables are all empty, then if condition does work.
So, thinking logically, we can conclude that either your variables aren’t empty or your condition does work.
You are supposed to verify both statements.
Unfortunately, nobody can tell whether your variables are empty or not. You have to do it yourself.
Same for the “not working” condition. Did you try to echo anything within it to make sure it doesn’t?
First stop, check for typos, especially a missing = sign. Always difficult when the code posted is not the actual code you have. Also after the header() line you should call exit() to stop execution of the remainder of the script.