naveenbj Posted January 9, 2008 Share Posted January 9, 2008 Hello Friends I was trying to validate a form . form has two blocks 1 is username and 2nd one is password . now wht i want is to validate this form not able to get any idea for this i kno it can be done by functions but not able to get the idea:( Regards, Nj Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/ Share on other sites More sharing options...
adam291086 Posted January 9, 2008 Share Posted January 9, 2008 google, php authentication scripts. Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434476 Share on other sites More sharing options...
JJohnsenDK Posted January 9, 2008 Share Posted January 9, 2008 hmm... how do you get the username and password, from a mysql database? if yes, then you open a connection to the database and check if the username exists, if it does you check if the password is equal to that users password in the database. If you just want it simpel it aint that hard to code. Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434478 Share on other sites More sharing options...
rajivgonsalves Posted January 9, 2008 Share Posted January 9, 2008 well you have to tell us what your validating against... a database... a text file... more info is required Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434480 Share on other sites More sharing options...
papaface Posted January 9, 2008 Share Posted January 9, 2008 Sounds like you don't actually know PHP at all, and are therefore not looking for help with a script you have actually written, but in fact looking for someone to write you a script. Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434481 Share on other sites More sharing options...
naveenbj Posted January 9, 2008 Author Share Posted January 9, 2008 Thanks to all for reply!! See im trying to validate this from local server so is this possible \?? If yes thn what will be my steps for this. Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434483 Share on other sites More sharing options...
naveenbj Posted January 9, 2008 Author Share Posted January 9, 2008 Sounds like you don't actually know PHP at all, and are therefore not looking for help with a script you have actually written, but in fact looking for someone to write you a script. Hello Im new to php but i hav the basic knolez but I dont want anyone to write script for me . i jst want to get sm help . Hope you can understand me:) Looking for guidelines always frm all:) regards, Nj Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434503 Share on other sites More sharing options...
trq Posted January 9, 2008 Share Posted January 9, 2008 Sounds like you don't actually know PHP at all, and are therefore not looking for help with a script you have actually written, but in fact looking for someone to write you a script. Hello Im new to php but i hav the basic knolez but I dont want anyone to write script for me . i jst want to get sm help . Hope you can understand me:) Looking for guidelines always frm all:) regards, Nj You don't have the basic knowledge. As Ive suggested to your ealier, there is a free book in my signiture that will get you started. getting us to write scipts for you is simply not how it works. This forum is for help with problems in your own code. if you have code with problems, post it, otherwise your going to need to look at some tutorials to get the basics down. Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434504 Share on other sites More sharing options...
naveenbj Posted January 9, 2008 Author Share Posted January 9, 2008 Sounds like you don't actually know PHP at all, and are therefore not looking for help with a script you have actually written, but in fact looking for someone to write you a script. Hello Im new to php but i hav the basic knolez but I dont want anyone to write script for me . i jst want to get sm help . Hope you can understand me:) Looking for guidelines always frm all:) regards, Nj You don't have the basic knowledge. As Ive suggested to your ealier, there is a free book in my signiture that will get you started. getting us to write scipts for you is simply not how it works. This forum is for help with problems in your own code. if you have code with problems, post it, otherwise your going to need to look at some tutorials to get the basics down. So i need to put the code here Ok Here is the code which i used <?php $strErrorMsg = ""; if (isset($_POST['submit'])) { if (empty($_POST['username'])) { $strErrorMsg .= "Username not entered"; } if (!empty($_POST['username']) && (!strcmp($_POST['username'])=='jimmy'))) { $strErrorMsg .= "Username is incorrect"; } if (empty($_POST['password'])) { $strErrorMsg .= "Password not entered"; } if(!empty($_POST['password']) && (!strcmp($_POST['password'])=='123456'))) { $strErrorMsg .= "Password is incorrect"; } ?> ------------------ Is it Ok to you .... Regards Nj Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434507 Share on other sites More sharing options...
Ken2k7 Posted January 9, 2008 Share Posted January 9, 2008 Read my comments. <?php $strErrorMsg = ""; if (isset($_POST['submit'])) { if (empty($_POST['username'])) { $strErrorMsg .= "Username not entered"; } // kind of useless to say !empty($_POST['username']) because you know it's not // empty since it passed the first IF statement. And just say // !preg_match("/jimmy/i",$_POST['username']) if (!empty($_POST['username']) && (!strcmp($_POST['username'])=='jimmy'))) { $strErrorMsg .= "Username is incorrect"; } if (empty($_POST['password'])) { $strErrorMsg .= "Password not entered"; } // again, you know $_POST['password'] is NOT empty here. // And say: $_POST['password'] != '123456' if(!empty($_POST['password']) && (!strcmp($_POST['password'])=='123456'))) { $strErrorMsg .= "Password is incorrect"; } ?> That is dear I say very ineffective. You're missing something at the end. All your code does so far is check if there are any errors. What if there isn't? What are you going to do then? Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434511 Share on other sites More sharing options...
naveenbj Posted January 9, 2008 Author Share Posted January 9, 2008 Read my comments. <?php $strErrorMsg = ""; if (isset($_POST['submit'])) { if (empty($_POST['username'])) { $strErrorMsg .= "Username not entered"; } // kind of useless to say !empty($_POST['username']) because you know it's not // empty since it passed the first IF statement. And just say // !preg_match("/jimmy/i",$_POST['username']) if (!empty($_POST['username']) && (!strcmp($_POST['username'])=='jimmy'))) { $strErrorMsg .= "Username is incorrect"; } if (empty($_POST['password'])) { $strErrorMsg .= "Password not entered"; } // again, you know $_POST['password'] is NOT empty here. // And say: $_POST['password'] != '123456' if(!empty($_POST['password']) && (!strcmp($_POST['password'])=='123456'))) { $strErrorMsg .= "Password is incorrect"; } ?> That is dear I say very ineffective. You're missing something at the end. All your code does so far is check if there are any errors. What if there isn't? What are you going to do then? Thn wht i have to do . If you can guide me it can be helpful for me:) ------ Thanks for ur support!! regards, Nj Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434515 Share on other sites More sharing options...
Ken2k7 Posted January 9, 2008 Share Posted January 9, 2008 You tell us. What should the code be doing if the user typed all the correct info? Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434521 Share on other sites More sharing options...
naveenbj Posted January 9, 2008 Author Share Posted January 9, 2008 Thanks for reply!! It will go to next page.. I mean to say it will verify and thn go to next page which is a form . Did you get wht i mean .. Regards, nj Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434522 Share on other sites More sharing options...
Ken2k7 Posted January 9, 2008 Share Posted January 9, 2008 Thanks for reply!! It will go to next page.. I mean to say it will verify and thn go to next page which is a form . Did you get wht i mean .. Regards, nj First, I really want you to listen to what thorpe said. Read up on basics. If you don't know how to even start on what you just told me, then you really need to learn them. Having us guide you through every letter, word and line isn't going to help you in the long run. So use header(). For something like this, you probably want to use $_SESSION or $_COOKIE to store the login info so that you can check if the user is logged in. Otherwise, people can just go to the next page without logging in. Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434668 Share on other sites More sharing options...
revraz Posted January 9, 2008 Share Posted January 9, 2008 http://www.amazon.com/How-Do-Everything-PHP-MySQL/dp/0072257954/ref=sr_1_22?ie=UTF8&s=books&qid=1199897357&sr=8-22 If you can guide me it can be helpful for me:) ------ Thanks for ur support!! regards, Nj Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434677 Share on other sites More sharing options...
naveenbj Posted January 9, 2008 Author Share Posted January 9, 2008 http://www.amazon.com/How-Do-Everything-PHP-MySQL/dp/0072257954/ref=sr_1_22?ie=UTF8&s=books&qid=1199897357&sr=8-22 If you can guide me it can be helpful for me:) ------ Thanks for ur support!! regards, Nj Quote Link to comment https://forums.phpfreaks.com/topic/85161-username-and-password-validationcan-any-one-help-me/#findComment-434837 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.