Jump to content

username and password validation??Can any one help me:)


naveenbj

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.