Hi
I would like to create a personal login page for people to record the number of times in a week/day/month that they perform a certain activity and have the ability to review their progress by loging in at anytime. I have looked through the forum and used this to creat 3 php files an inserted in to HTML of page:
login.php:
<html>
<head>
<?php require("login3.php"); ?>
<title>Please login</title>
</head>
<body>
<?php
if(isset($_GET["wrong"])){
echo("<b>Username or password is incorrect!<br />Please try again.</b>");
}
?>
<form action="login2.php" method="post">
<br />
Username:<br />
<input type="text" name="username" /><br />
Password:<br />
<input type="password" name="password" />
<br />
<br />
<input type="submit" value="Login" />
</form>
</body>
</html>
login2.php:
<?php require("login3.php"); ?>
<?php
$usernames = array("user1", "user2", "user3", "superman");
$passwords = array("pass1", "pass2", "password3", "supermans password");
$page = "mypage.php";
for($i=0;$i<count($usernames);$i++){
$logindata[$usernames[$i]]=$passwords[$i];
}
if($logindata[$_POST["username"]]==$_POST["password"]){
session_start();
$_SESSION["username"]=$_POST["username"];
header('Location: '.$page);
exit;
}else{
header('Location: login.php?wrong=1');
exit;
}
?>
login3.php:
<?php require("login3.php"); ?>
<?php
session_start();
if(!isset($_SESSION["username"]){
header('Location: login.php');
exit;
}
?>
I am very new to all this so I would appreciate step by step assistance
Thanks
I would like to create a personal login page for people to record the number of times in a week/day/month that they perform a certain activity and have the ability to review their progress by loging in at anytime. I have looked through the forum and used this to creat 3 php files an inserted in to HTML of page:
login.php:
<html>
<head>
<?php require("login3.php"); ?>
<title>Please login</title>
</head>
<body>
<?php
if(isset($_GET["wrong"])){
echo("<b>Username or password is incorrect!<br />Please try again.</b>");
}
?>
<form action="login2.php" method="post">
<br />
Username:<br />
<input type="text" name="username" /><br />
Password:<br />
<input type="password" name="password" />
<br />
<br />
<input type="submit" value="Login" />
</form>
</body>
</html>
login2.php:
<?php require("login3.php"); ?>
<?php
$usernames = array("user1", "user2", "user3", "superman");
$passwords = array("pass1", "pass2", "password3", "supermans password");
$page = "mypage.php";
for($i=0;$i<count($usernames);$i++){
$logindata[$usernames[$i]]=$passwords[$i];
}
if($logindata[$_POST["username"]]==$_POST["password"]){
session_start();
$_SESSION["username"]=$_POST["username"];
header('Location: '.$page);
exit;
}else{
header('Location: login.php?wrong=1');
exit;
}
?>
login3.php:
<?php require("login3.php"); ?>
<?php
session_start();
if(!isset($_SESSION["username"]){
header('Location: login.php');
exit;
}
?>
I am very new to all this so I would appreciate step by step assistance
Thanks