Highlighted

Password protect login page dreamweaver cc entering wrong details still passes request

Explorer ,
Jul 24, 2020

Copy link to clipboard

Copied

<?php

$username = "****";

$password = "****";

if(isset($_POST['submit'])) {

$username = $_POST['username'];

$password = $_POST['password'];

if($username != "Pivington") {

$error['username'] = "Wrong Username";

}

if($password != "Piv2020!") {

$error['password'] = "Wrong Password";

}

}

?>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8"/>

<title>Secure Information</title>

</head>

<body>

<?php if($username == "Pivington" && $password == "Piv2020!") { ?>

<h1>Welcome</h1>

<!-- PROTECTED INFORMATION GOES HERE -->

<?php } else { ?>

<h2>Login</h2>

<?php foreach($error as $errors) {

echo "<p style='color: red;'>".$errors."</p>";

}

?>

<form name="login" action="potload.html" method="post">

<p>

<label for="username">Username</label>

<input type="text" id="username" class="username" name="username" placeholder="Username" value="<?php if(isset($username)) { echo $username; } ?>">

</p>

<p>

<label for="password">Password</label>

<input type="text" id="password" class="password" name="password" placeholder="Password" value="<?php if(isset($password)) { echo $password; } ?>">

</p>

<p>

<input type="submit" name="submit" value="Submit">

</p>

<?php } ?>

</form>

</body>

</html>

Views

45

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Password protect login page dreamweaver cc entering wrong details still passes request

Explorer ,
Jul 24, 2020

Copy link to clipboard

Copied

<?php

$username = "****";

$password = "****";

if(isset($_POST['submit'])) {

$username = $_POST['username'];

$password = $_POST['password'];

if($username != "Pivington") {

$error['username'] = "Wrong Username";

}

if($password != "Piv2020!") {

$error['password'] = "Wrong Password";

}

}

?>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8"/>

<title>Secure Information</title>

</head>

<body>

<?php if($username == "Pivington" && $password == "Piv2020!") { ?>

<h1>Welcome</h1>

<!-- PROTECTED INFORMATION GOES HERE -->

<?php } else { ?>

<h2>Login</h2>

<?php foreach($error as $errors) {

echo "<p style='color: red;'>".$errors."</p>";

}

?>

<form name="login" action="potload.html" method="post">

<p>

<label for="username">Username</label>

<input type="text" id="username" class="username" name="username" placeholder="Username" value="<?php if(isset($username)) { echo $username; } ?>">

</p>

<p>

<label for="password">Password</label>

<input type="text" id="password" class="password" name="password" placeholder="Password" value="<?php if(isset($password)) { echo $password; } ?>">

</p>

<p>

<input type="submit" name="submit" value="Submit">

</p>

<?php } ?>

</form>

</body>

</html>

Views

46

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 24, 2020 0
Most Valuable Participant ,
Jul 24, 2020

Copy link to clipboard

Copied

I hope that isn't the real password, now shared with the world forever !!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 24, 2020 0
Adobe Community Professional ,
Jul 24, 2020

Copy link to clipboard

Copied

I moved your post over from the poorly named Community Help forum, which is for getting help using this forum system, to a better forum.


I hope this helps. Best of luck to you.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 24, 2020 0
LEGEND ,
Jul 24, 2020

Copy link to clipboard

Copied

That's because you have NOT set your login forms 'action attribute' to go back to the page the login form is on, the 'action attribute' has been set to go to potload.html instead. If you set that as the action once you click the 'submit' button it will go straight to that page bypassing the php script which checks the details from you login form.

 

action="potload.html"

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 24, 2020 0
Adobe Community Professional ,
Jul 24, 2020

Copy link to clipboard

Copied

Try this simple password protected page and save as protect.php.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Password Protected Content</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<!--minimal demo styles-->
<style>
html {font-size:16px}

body {font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, "sans-serif";
font-size: 1.5rem;
width:80%;
margin:0 auto;
}
</style>
</head>
<body>

<?php
// Define your username and password here
$username = "admin";
$password = "pass123";

if (isset($_POST['txtUsername']) != $username || $_POST['txtPassword'] != $password) {
?>
<!--LOG-IN FORM-->
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<fieldset>
<legend>Log-In</legend>

<p><label for="txtUsername">Username:</label>
<br>
<input type="text" title="Enter your Username" name="txtUsername" id="txtUsername" required placeholder="5 characters"></p>

<p><label for="txtPassword">Password:</label>
<br>
<input type="password" title="Enter your password" name="txtPassword" id="txtPassword" required placeholder="7 characters"></p>

<button type="submit" class="btn btn-lg btn-primary">Submit</button>
</fieldset>
</form>

<?php
}
else {
?>

<!--PROTECTED CONTENT-->
<h2>Log-In Success!</h2>
<p>You have reached a password protected area of this page. What would you like to do next?</p>

<!--Links to other pages-->
<ul>
<li> <a href="download.html">Download Files</a></li>
<li><a href="#">Upload Files</a></li>
<li><a href="#">Watch Videos</a></li>
<li><a href="#">Play a Game</a></li>
</ul>
<?php
}
?> 
<!--END PROTECTED CONTENT-->

</body>
</html>
Nancy O'Shea, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 24, 2020 0