Here in your code:
it should be:
a single = sign means you're assigning the value "true" to the variable $result, thus making the condition always true. So it goes there no matter the result actually succeeds or fails. a double = sign works as a comparison, but a triple = sign is safer as it also checks the type of the variable.