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.
|
|
|