Hi i have this code, i am using php, html5 in notepad ++ <?php session_start();
ID: 670785 • Letter: H
Question
Hi i have this code, i am using php, html5 in notepad ++
<?php
session_start(); // start the session
if (isset($_POST['username'])) { // check is the username and password is correct
if ($_POST['username']=='foo' and $_POST['pwd']=='bar') {
$_SESSION['loggedin'] = True; // set session loggedin as True
}
}
else {
}
// redirect to home if already logged in
if ($_SESSION['loggedin']==True) {
//echo "You are logged in";
header("Location: home.php");
}
$title = "login"; // to identify the page
?>
<!DOCTYPE html>
<html>
<head>
<title>Log In</title>
<link rel="stylesheet" type="text/css" href="home.css"/>
</head>
<body>
<div id="container">
<div id="header">
<h1>COMP233 Assignment-3</h1>
</div>
<div id="content">
<h3>Login</h3>
<hr/>
<!-- login form -->
<form action="login.php" method="post">
Username: <input type="text" name="username"><br/>
Password: <input type="password" name="pwd"><br/><br/>
<h2>Home<h2>
<h2>Page One<h2>
<h2>Page Two<h2>
<h2>Page Three<h2>
<h2>Login<h2>
<input type="submit" value="Submit">
</form>
<br/>
</div>
</div>
</div>
</body>
</html>
can you please provide the correct css to make this coding look like...
Explanation / Answer
<?php
session_start(); // start the session
if (isset($_POST['username'])) { // check is the username and password is correct
if ($_POST['username']=='foo' and $_POST['pwd']=='bar') {
$_SESSION['loggedin'] = True; // set session loggedin as True
}
}
else {
}
// redirect to home if already logged in
if ($_SESSION['loggedin']==True) {
//echo "You are logged in";
header("Location: home.php");
}
$title = "login"; // to identify the page
?>
<!DOCTYPE html>
<html>
<head>
<title>Log In</title>
<link rel="stylesheet" type="text/css" href="home.css"/>
<style>
.self {
font-family: "Verdana" ;
font-size:30px;
}
</style>
</head>
<body>
<div>
<h1>COMP233 Assignment-3</h1>
</div>
<div>
<!-- login form -->
<table>
<tr>
<td>
<h2>Home<h2>
<h2>Page One<h2>
<h2>Page Two<h2>
<h2>Page Three<h2>
<h2>Login<h2>
</td>
<td>
<center>
<h3 class="self">Login</h3>
<form action="login.php" method="post">
Username: <input type="text" name="username"><br/><br/>
Password: <input type="password" name="pwd"><br/><br/>
<input type="submit" value="Login">
</center>
</td>
</tr>
</table>
</form>
<br/>
</div>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.