task 2

task 2
<!DOCTYPE html>
<html lang=”en”>
<head>
    <meta charset=”UTF-8″>
    <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
    <title>Document</title>
</head>
<center>
    <fieldset>
<?php
    session_start();
    if(isset($_SESSION[‘username’])
    )
    {
        echo “User Name:”.$_SESSION[‘username’];
    }
?>
    </fieldset>
</center>
</body>
</html>
 
 
 
 
<!DOCTYPE html>
<html>
<head>
    <meta charset=”utf-8″>
    <meta name=”viewport” content=”width=device-width, initial-scale=1″>
    <title>Login Page</title>
</head>
<body>
<center>
    <fieldset>
        <legend><i>Login Page</i></legend>
        <form method = “post” action =”login.php”>
            <table>
                <tr>
                    <td>Username:</td>
                    <td><input type=”text” name=”username”> </td>
                </tr>
                <tr>
                    <td>Password:</td>
                    <td><input type=”password” name=”password”></td>
                </tr>
                <tr>
                    <td><input type=”submit” name=”login” value=”Login”></td>
                    <td><input type=”submit” name=”reg” value=”New user?”></td>
                </tr>
            </table>
        </form>
    </fieldset>
</center>
<?php
    if(isset($_POST[‘login’]))
    {
        $username = $_POST[‘username’];
        $password = $_POST[‘password’];
        if($username ==’Jewel’ && $password ==’bbb’)
        {
            session_start();
            $_SESSION[‘username’]= $username;
       
           

            header(“location: Home.php”);
        }

        else
        {
            echo”password don’t match”;
        }
       
    }

?>
</body>
</html>
<?php
    if(isset($_POST[‘reg’]))
    {
        header(“location: reg.php”);
       
    }
?>
Scroll to Top