signup form issue php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: signup form issue php

Post by Celauran »

As the notice says, $error is not defined. Since you never declare or instantiate the variable, it gets instantiated to null when you compare against it on line 25. A loose comparison (== as opposed to ===) of null and empty string evaluates to true. You then display the success message before any validation has been done.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: signup form issue php

Post by Celauran »

$error isn't being used here. You haven't defined it, you never assign anything to it. What you probably want to do is break this into two steps; first validate the submission (this is where you could make use of your currently unused $error variable), then do something with the data if validation passes.
Post Reply