473,704 Members | 4,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to check whether the username and password entered in a login php form are valid

13 New Member
Could anyone please tel me in detail ... How to check whether the username and password entered by user in a login php form are valid ... I have not created any database ...

I already have created a registration form , in which user enters his details ... But how can i make sure that in login form, he enters the same id and password ....

Regards,
Shwetha
Sep 18 '08 #1
3 4195
dlite922
1,584 Recognized Expert Top Contributor
you get the the record in the database for the username he's giving you, if any exist.

Then get the stored password and compare it to the one he entered. If they are the same, he's validated.

Are you talking about some other validation?



Dan
Sep 18 '08 #2
divyac
40 New Member
Hi shwetha,
First you must send all the values from the registration form to the database and try out the below code...
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. if(isset($_POST['<submit button name>']))
  4. {
  5.  
  6.        $result=mysql_query("SELECT * FROM tablename WHERE <name field from database>='$_POST[<textbox name of name>]' and <password field from database>='$_POST[<textbox name of password>]'");
  7.  
  8. $row=mysql_num_rows($result);
  9.  
  10. if($row>0)
  11. {
  12.     header('location:<specifipage>.php');
  13. }
  14. else
  15. {
  16.     alert(Incorrect username and password);
  17. }
  18. }
  19. ?>
  20.  
Hope this works....
Sep 18 '08 #3
Markus
6,050 Recognized Expert Expert
First of all you're going to have to create a database table. You could use flat files... but that's more effort than what's required.
Sep 18 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

15
2286
by: carr4895 | last post by:
Hello. I was wondering if someone could help me too with a login form. Upon startup, I have to display a password screen and it should accept a user name and password. User name can be anything non-blank. If there is no user name, an appropriate error message must be displayed. All of the following passwords are valid IT160, VB2Manager, BackDoor. No other password is valid. It must allow the user to enter the password in any case. If...
0
1593
by: None | last post by:
Hi, I have written a c# code to find the given username and password is correct or not. (i.e the given username and password will be checked against the active directory) But i don't know how to check the username and password for WorkGroup machine. The difficulty i'm facing is that i don' know how to assign correct path to DirectoryEntry Class constructor This is working fine for Domain machine
10
2237
by: priyakollu | last post by:
hi guyz! please help me in sorting out error as im unable to find it... my requirement is there will be userid field and password field and "login" button after clicking button certain validations must be done whether he is an valid user or not (connect to database and check for valid user & password) if he is valid user he must login and goto another php file..... im using winxp OS / XAMPP Windows Version 1.6.4 ! Problem: im getting...
2
1517
by: sweatha | last post by:
I have created a login form in asp.net web page.Just like that I have created a table named login which has 2 fields as username & password in SQL Server 2000. I have to check whether the data(username & password) entered in the front end is available(exists) in the back end (SQL Server 2000) or not.
8
6262
by: Mai Le | last post by:
Hello, I used Microsoft Access to create a login form with Name Password Access Level Admin and User I would like to let Admin login and open MRB form and User login then open other form like "test" Please show me how to do it Thanks in advance I had code below
1
2006
by: geetamadhavi | last post by:
Hi All, I have developed a php applciaiton where a new window is opening on checking the whether valid user orntot how to make that in same window after checking i have die(' not valid user ' ); i even tried with echo also how to solve this the message should come under in the same window only see my code it is program ---- <?php // Connects to your Database mysql_connect('localhost', 'root', 'epara') or die(mysql_error());
5
4068
by: Sudhir123 | last post by:
Hi.. I need to find out whether user has entered only black spaces or some text which might have some spaces.. But i more interested to check for blanck spaces (by spacebar key). how i will find out this. I used trim function, but it trims text also..i m using my own framework which i built for application. Plz suggest me somthing.. following functions are not working. element.length==0 and element==null
6
1730
by: amd321 | last post by:
i want to make a site that can check if some password that i have is good. the software need to go to the site. and check whether the password is good. how can i do it?
1
1140
by: amd321 | last post by:
i want to make a site that can check if some password that i have is good. the software need to go to the site. and check whether the password is good. how can i do it?
0
8766
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9271
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9134
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8975
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5930
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3134
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2478
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2078
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.