here is the link to the picture httpoi59tinypiccom33kvdsgjpg

here is the link to the picture: http://oi59.tinypic.com/33kvdsg.jpg

Dropbox Assignment 11 Create an access restricted php page with the following tasks (every step below must be strictly followed, e.g. the text file must be called student.txt and must be inside C: data .) 1. Create a plain text file with at least two pairs of student username and password. Each username or password takes a whole line. For example, if you have two pairs of username and password, the text file will contain four lines. Create a folder named data in C drive. Save the file as student.txt and inside C: data (so the path to the file is C: data studenttxt). 2. Create a login.php page with a simple form. The form method is post and the action is assignmentl la.php. The form should contain two textboxes, one for username and the other for password. The form also has a button for submission. In addition to the HTML codes for the form above, use a session variable to show an error message if the username or password is invalid. The error message is generated in assignmentl la.php described below. 3. Create an assignmentl la.php page that gets the values entered by the user from login.php (step 2 above) and retrieve data from student.txt (step 1 above). Then the codes will compare the two sets of values. If a match is found, a new page (described below) assignmentl lb.php will show up. Otherwise, show the login.php page with an error message (use a session variable). 4. Create an assignmentllb.php page. This page is restricted to visitors whose username and password shown in the student.txt file. When an authorized user visits this page, he/she will see the following message on the page: Hello, username. You are reading a member-only page. Please logout when you have completed reading the page. The word logout should be linked to a logout.php page described next. Whe n an unauthorized user visits the page, he/she will see the following message on the page: Hello, Guest You are visiting a member-only page. If you are a member, please login. The word login should be linked to the login.php page described in step 2 above. 5. Create a logout.php page. This page destroys all cookies/sessions created and contains the following line of text: You have logged out. You need to login again if you want to see member-only page. The word login should be linked to login.php described in step 2 above. 6. Put all 5 files in a zipped folder named assignmentll and upload it to the dropbox.

Solution

<?php session_start(); ?>
<?php
$username = trim($_POST[\'username\']);
$password = trim($_POST[\'password\']);

if (isset($_POST[\'submitBtn\']))
{
$lines = array();
$lines = explode(\"\ \",file_get_contents(\"C:\\data\\student.txt\"));
$found=0;
for ($x=0;$x<sizeof($lines);)
{
$found=0;
if($username==trim($lines[$x]))
{
$found=1;
break;
}
$x+=2;
}
if($found==1)
{
if($password==trim($lines[$x+1]))
{
$_SESSION[\'user\']=$username;
header(\"Location:assignment11b.php\");
}
else
{
header(\"Location:login.php\");
$_SESSION[\'loginFailed\']=\'Invalid Credential/ Check Your CAPSLOCK and try again\';
}
}
else
{
header(\"Location:login.php\");
$_SESSION[\'loginFailed\']=\'Invalid Credential/ Check Your CAPSLOCK and try again\';
}

}
?>


Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site