Is this correct? If not what is the correct syntax
I am new to php hence trying to learn.
It won't work, because induces a behavior in the browser, and you are checking your condition server side.