Simple authorization script without MySQL

Rizwan

Moderator
Staff member
Step 1
First, let's look at option 1, which is the same type of login and password.
Open notepad, copy and paste the below script into notepad.
Code:
<?
$login_user=“admin”;
$password_user=“admin”;
$login=$POST['login'];
$password=$POST['password'];
if( ($login_user == $login) and ($password_user == $password) )
{
echo “Welcome”;
}
else
{
echo “Incorrect login or password”;
}
?>
Next, click “File”, select “Save As...”
A window will pop up. Write the file name “registr.php” in the field.
Set the encoding to “UTF-8” (optional)
Save.
Copy the following script:
<html>
<head><title>Authorization</title></head>
<body>
<form method="POST" action="registr.php">
<table border="1">
<tr ><td>Login</td><td><input type="text" name="login"></td></tr>
<tr><td>Password</td><td><input type ="password" name="password"></td></tr>
<tr><td><input type="Submit" value="Login"></td><td></td></ tr>
</table> </form> </body> </html>
Save it with the name “index.html”.
The script is ready for use.
Step 2
2) Authorization with a mini database.
Copy and save the PHP script into notepad. The script name is “registr.php”.
<?
//mini database
$login_user=“admin”;
$password_user=“admin”;
$login_user1=“admin2”;
$password_user1=“admin2”;
$login_user2=“admin3”;
$password_user2=“admin3”;
//end of the mini database
//processing of information received from the user
$login=$POST['login'];
$password=$POST['password'];
if
(
($login_user == $login) and ($password_user == $password)
or
($login_user1 == $login) and ($password_user1 == $password)
or
($login_user2 == $login) and ($password_user2 == $password)
)
{
echo “Welcome”;
}
else
{
echo “Incorrect login or password”;
}
?>

I hope there is nothing complicated here.
index.html is the same as for 1st authorization option.
The script is ready for use.
Step 3
Warnings:
PHP scripts will not work in a regular browser.

Decide for yourself, good mood everyone, that’s all...Bye
 
Back
Top