Validity of username and passwords - PHP / MySQL Tutorials
 
  Buy Ebooks, Video Games, DVDs, Electronics and more !
Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads Make Money Online Blog . Free Image and Photo Sharing and Hosting

 

 

Company

Home

Nework Details

Tutorials

SWiSH 2

SWiSHMax

Flash MX

PHP & MySQL

HTML / JScript

Adobe Photoshop

Corel Draw

Gimp

Miscellaneous

Downloads

Templates

Plugins

Fonts

Wallpapers

Free Images

Scripts and Codes

Products

E-Books

SWiSH BB

SWiSH Templates

SWiSH-DB Newsletter
Subscribe to our newsletter : GO
  Partners / Affiliates

   Free image hosting
   Web Design Pakistan
   Swish Templates
   SWiSH Climax
   Talkfreelance Community
   Template Desire
   Lite boards
   Script Sector
   GimpTalk
   13dots
   Idea Designs
   PHP Cafe
   Sposatoettore
   Free swishmax templates
   Swishzone

Manage your site with Flax Article Content Management System
Validity of username and passwords
Category : PHP / MySQL | Level : Beginner | Language : English
Ask Question | Read Comments | Post tutorial | Previous | Next

Web www.swish-db.com


We have assumed that you have created a table called "users", and that table contain as much fields as you want, you can insert records
into that table using a form in html. But be sure to include two fields:
name= it is the username of the user
password= it is the password of each user
Simply create a form, using html, and set the action of that forum to a php file where you will include this small piece of code:

<?php
//First lets get the username and password from the user
$username=$_POST["username"];
$password=$_POST["password"];
//Second let's check if that username and password are correct and found in our database
$sql1=mysql_query("SELECT name, password FROM users WHERE name='$username' AND password='$password'")
if (mysql_num_rows($sql1)==0 || mysql_num_rows($sql1)>1)
{ echo "Sorry, the username and password you submitted are not present in our database";
}
//if there are found in our database, and there is only one occurence of that username and password
//thus making them valid, so inside, you can include the webpage you want to open
if(mysql_num_rows($sql1)==1)
{
include("the webpage"); //open up the secure page //instead of "the webpage" type in the path your secure website is located in
}
?>

I know it is a beginner level way to restrict access to a webpage, but it seems to work fine, for a single webpage. Check it out, might be useful.
smile.gif


© 2002-2005 Flaxweb Network | Article Manager | Gimp Tutorials Library | RAD C++ Library | Free C/C++ Sourcecode |
Sites of interest : Web Design Blog | Swish Templates | Swishmax Ebook | Photoshop Templates | Gimp Tutorials | Text Forum | Make Money Online