i want to make a login thing but i dont know how. does anybody here know how to?
i want to make a login thing but i dont know how. does anybody here know how to?
go to w3schools.com it tells you how somewhere... :P
Make a sql database with the usernames / passwords (this is very basic) and do a sql query.
Alternatively if you wanted it to be a basic (VERY BASIC) you could do this:
login.html:
<html>
<head>
<title>Login</title>
</head>
<body>
<table>
<form action="protectedarea.php" method="post">
<tr><td>Username:</td><td><input type="text" name="username"></td></tr>
<tr><td>Password:</td><td><input type="password" name="password"></td></tr>
</form>
</table>
</body>
</html>
Then make a file called protectedarea.php and put this:
<html>
<head>
<title>Protected area!</title>
</head>
<body>
<?
$password = $_POST['password']
if ($password == "this is where you put the value of the password.")
{
echo "You have successfully logged in.";
}
else
{
echo "You have entered an invalid username / password!";
}
?>
</body>
</html>
What that does is check if the user entered the password you have set.
NOTE:This only works on one page. If they go to another page they won't be prompted to login.
protectedarea.php is the only page that is password protected.
THIS DOES NOT USE SESSIONS AND IS REALLY BASIC!
~~~
You could also just make a dictionary and use the CPanels function to password protect it.
That way would be better..
Last edited by sonicsshadow; 01-04-2008 at 09:24 PM.
Login to cPanel and hit password protect directories
theres tutorials at webdesign.org
This would be the script for the login form
<html>
<title>Login</title>
<body>
<form action="userlogin.php">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
<input type="submit" value="login">
</form>
save that as login.html then make a file called userlogin.php
and put this in it...
<?php
//Check for required forms in the fields
if (empty($_POST["username"])) || (empty($_POST["password"])))
{
header("Location: login.html");
exit;
}
//Connects to database
$mysqli = mysqli_connect("Your Mysql server", "Databases Username", "Databases Password", "Database Name");
//Create and issue the query
$sql = "SELECT * FROM auth_users WHERE username = '".$_POST["username"]."' AND password = PASSWORD('".$_POST["password"]."')";
$result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli));
//get the number of rows in the result set; should be 1 if a match
if (mysqli_num_rows($result) == 1) {
//Set Authorization Cookie
setcookie("auth", "1", 0, "/", "Your Websites Name", 0);
?>
<body>You Are Authorized!!!</body>
<?
} else {
?>
<body>You are unauthorized </body>
<?
}
?>
But you have to have a database for this onesorry if I made a stupid typo, I hope I didn't
![]()
use Front Page
it's easy way to make login page:cool: