Login Page

Sec Expert

New Member
سلام من می خوام روی فقط یک صفحه یوزر نیم و پسورد تعریف کنم به طوریکه فقط اون صفحه با یوزرنیم و پسورد در دسترس باشه کسی می تونه کمک کنه البته این رو پیدا کردم منتها چون خیلی توی php و html مبتدی هستم چیزی نفهمیدم
كسي مي تونه اين رو براي من توضيح بده من اين رو از يه جايي كپي كردم اين طور كه خودش مي گه براي پسورد گذاري روي يك صفحه مناسب هست اما این قسمت رو نمی فهمم چون من خیلی مبتدی ام: مي گه كه ما فرض رو بر اين گرفتيم كه شما يك table به نام users ساخته اید و اون table شامل تعداد دلخواهی فیلد میشه و شما قادرید با استفاده از یک فرم در html رکوردهایی رو در آن table قرار دهید.مطمئن شوید که دو فیلد یوزرنیم و پسورد را در آن قرار مي دهید.با استفاده از html یک فرم ایجاد کنید و action آن فرم را فایل php ای تعیین کنید که این تکه کد را در بر دارد


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.
اگه راه ساده تری هم می شناسید لطفا" کمک کنید ممنون
 

جدیدترین ارسال ها

بالا