<?php
session_start();
define ('USERNAME', 'Stephenturkson');
define ('PASSWORD', 'something');
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$username = $_POST['username'];
$username = $_POST['password'];
}
if( $username === USERNAME && $password === PASSWORD){
$_SESSION['username'] = $username;
header("Location: admin.php");
}
?>
<!doctype html>
<html>
<head>
<title>Login Form</title>
<style>
form ul { padding: 0; margin: 0;}
form li{ list-style: none; margin-bottom: 1em;}
</style>
</head>
<body>
<h1>Login</h1>
<form action="index.php" method="post">
<ul>
<li>
<label for="name">Name: </label>
<input name="name" type="text">
</li>
<li>
<label for="password">Password: </label>
<input name="password" type="password">
</li>
<li>
<input type="submit" value="Login" name="submit">
</li>
</ul>
</body>
</html>
$username = $_POST['username'];
$username = $_POST['password'];
Did you mean to use the same varname?
If that doesn’t help, what was the question?
Also,
In your PHP code, you’re trying to retrieve a POST variable called ‘username’, but your form input is named ‘name’.
exactly. that was the issue
i couldnt sleep last night ,
thanks .
boss it was an issue with my html form its been solved. thanks
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.