开发者

PHP loggin system doubt

开发者 https://www.devze.com 2023-01-25 09:47 出处:网络
Im new to php and im trying to develo a loggin system, but i cant understand one thing. For Example: I hava a object \"validator\", that do some field checks. In that object i have an array where i

Im new to php and im trying to develo a loggin system, but i cant understand one thing.

For Example:

I hava a object "validator", that do some field checks. In that object i have an array where i save the errors. Like "The password you choose is not valid". Now i want to show this error to the user, the way i do it is passing this array to a Session variable. However i dont like this way of doing it. I create a new object everyt开发者_JS百科ime a user submits a form to validate it, but i dont know how to associate that validator object to te user. I want to say "this object belongs to that user".

Thanks,


I think the best way to achieve this goal is to validate your fields with Javascript. There is a lot of tutorials on how to validate fields with Javascript on the internet.

However, if you really want to use PHP, you just need to use the POST method and reload the form's page. Then, with your PHP script, you can validate all fields with your "Validator" object.

Note that you should always validate server side everything you insert in your database. The javascript is only for the UI. Thanks maniator, I wasn't clear enought.

Jean-Philippe

0

精彩评论

暂无评论...
验证码 换一张
取 消