Jump to content
xisto Community
veerumits

Php Code For Login Form With Validation In Php

Recommended Posts

I dont want to use javascript as a validation form i want to use Regular expression in PHP for Login or other page. please any one have a best code for validation in PHP. as i thinks that web site Validation on server site is faster then client site validation. Most welcome.

Share this post


Link to post
Share on other sites

I do not know the php code for web form validation in my head, i could find it in my computer when i get home, but i can tel lyou now that, with my experience, javascript is better for the validation of web forms, and besides, most of web designers use javascript to validate their web forms because it is very simple, allthough the php code e could be simple too, i do not know it for now, sorry, perhaps later.

Share this post


Link to post
Share on other sites

I dont want to use javascript as a validation form i want to use Regular expression in PHP for Login or other page. please any one have a best code for validation in PHP. as i thinks that web site Validation on server site is faster then client site validation. Most welcome.


Using javascript to validate user input is nice because it doesn't require the user to have to reload the page, the browser does all the work, however the problem with solely using javascript is that it could easily be modified to allow users to bypass whatever validation javascript is running. You could use ajax to have javascript validate the data with the server but that is even more pointless. What I would personally recommend if you wanted to make your website both user-friendly and secure, have both javascript and php check validation of the input. Javascript will easily alert users if the input they entered does not match what the website expects, and users who either disable javascript or attempt to get around this will have a php error message returning the same error javascript returned.

As for using regular expressions, we can't exactly give you any code unless you tell us what exactly you want to allow or deny in the string.

Share this post


Link to post
Share on other sites

Using javascript to validate user input is nice because it doesn't require the user to have to reload the page,
As for using regular expressions, we can't exactly give you any code unless you tell us what exactly you want to allow or deny in the string.


Yes. I agree with galexcd. Javascript for validating is the best and fastest option. Because all the validation will be done on clients browser. So it will be obviously the fastest. And also user friendly. Why? because the user correct all his mistakes at one time before submitting the page to server. If all the validation will be done at the server side, user feels it annoying because he need to submit the page many times to correct all his mistakes. It is a time taking process for the user and is very slow.

So validating it on client side is best. And also it saves some process haedache of server. But of course, server side validation should also be implemented. As galexcd said, it is very easy to change everything which is on client side and bypass any restrictions they have. This can lead to some security issues. So, server side validation is also needed. Since, client side validation is already done, the data is valid most of the time, and no need to repeat the process again....

And about regular expressions, how can we give if we don't know what you and your code need? Give us complete details and we'll help you.

Share this post


Link to post
Share on other sites

I agree with everything said already. You should use a Javascript validation to check every key press and see if that keypress is any of the following: " ' : , . @ | $ ? % ^ & * ( ) and so on.....Then in the PHP validation use a regular expression of the format: /w that should check for all alpha-numeric characters (a-z 0-9) you can also add a character limit with something like {5,20} (which is: {min,max} )Im not very good with regex otherwise i would write the whole thing for you, but it gives you a starting block

Share this post


Link to post
Share on other sites

as for galexcd said, using javascript for validation is more appropriate than php.. client-base is much better and it is user friendly than php.. but you should also have php validation after.. you can search for codes in google..

Share this post


Link to post
Share on other sites

I agree with everything said already. You should use a Javascript validation to check every key press and see if that keypress is any of the following: " ' : , . @ | $ Ł % ^ & * ( ) and so on.....
Then in the PHP validation use a regular expression of the format: /w that should check for all alpha-numeric characters (a-z 0-9) you can also add a character limit with something like {5,20} (which is: {min,max} )

Im not very good with regex otherwise i would write the whole thing for you, but it gives you a starting block


Try this one: if(ctype_alnum($_REQUEST["user"])){ [..] }

There's probably other similar functions except I just opened a random file and looked what was inside and that's all I found! Regular expressions are much slower than this type of check, so it's better to use something like this. Or so I've heard.

Share this post


Link to post
Share on other sites
I disagree with most of youPhp Code For Login Form With Validation In Php

Javascript is not better for form validations. It is ok if you trust your users but as a matter of principal one should assume that every user has malicious intent. There are many ways to get around javascript validations. The easiest being as simple as turning javascripting off. If you work around that by using javascript to create the forms then a user could just make thier own forms.What really matters is not the users process of forming their input to meet the requirments for sending data to the server. What really matters is the actual data that is being processed by the server. If you don't validate and secure the actual process that is handling the information then you might as well not do any validation at all.You must secure that chokepoint. If you control the entrance then nobody can get in. If you go wander up and down the sidewalk and hassling people on their way to your house they may just hop over the fence beside your house walk in the front door while you are stomping about the street.Use php to secure your input.

-reply by Generic Guy In Trenchcoat

Share this post


Link to post
Share on other sites
signup form creation for different type of users in phpPhp Code For Login Form With Validation In Php

I have two type of users 1. Freelancer and 2.Webmaster , two text areas username &  password if I fillup the two columns then I click freelancer radio button the information goes to database table freelancer / if I selected webmaster the information goes to the webmaster table in the database please send code in php. 

Share this post


Link to post
Share on other sites

It doesn't matter which you use to validate form, because you can get a special character into an HTML element without actually typing it in (Javascript injecting), and therefore you'd need to validate the form in PHP anyways- especially if the user's JS is turned off. Save yourself the trouble and just validate it in PHP.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.