不同的密码如何重定向到 php 和 html 中的不同页面
How differents password redirect to differents pages in php and html
如何使用密码重定向到具有不同密码的不同页面。
回声丢失了一些东西,我想我应该添加一个数组。回声倍数如何回声... Grrr
我有 3 个密码,想使用这些密码重定向到 3 个不同的页面??
<?php
// Rename this file to config.php
$password05 = "fogy05";
$password10 = "fogy10";
$password20 = "fogy20";
$redirect05 = "download/05/index.html";
$redirect10 = "download/10/index.html";
$redirect20 = "download/20/index.html";
$require_https = true;
<?php
require_once("config.php");
if ($require_https && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on')) {
if(!headers_sent()) {
header("Status: 301 Moved Permanently");
header(sprintf(
'Location: https://%s%s',
$_SERVER['HTTP_HOST'],
$_SERVER['REQUEST_URI']
));
exit();
}
}
if (isset($_POST['password'])) {
if ($_POST['password'] === $password05) {
$success = true;
}
elseif (strlen($_POST['password05']) == 0) {
$alert = "Password cannot be empty.";
}
else {
$alert = "Password incorrect. Please try again.";
}
}
?>
<?php if ($success) { ?><meta http-equiv="refresh" content="3;URL=<?php echo $redirect ?>"><?php } ?>
<form class="form-signin" role="form" method="POST">
<?php if ($success) { ?>
<div class="alert alert-success" role="alert"><b>Code valide. Redirection...</b></div>
<?php } else { ?>
<?php if(isset($alert)) { ?>
<div class="alert alert-danger" role="alert"><b><?php echo $alert ?></b></div>
<?php } ?>
<h2 class="form-signin-heading">Veuillez entrer votre code</h2>
<input type="password" name="password" class="form-control" placeholder="Password" autocomplete="off" autofocus>
<button class="btn btn-lg btn-primary btn-block" type="submit">Go</button>
<?php } ?>
</form>
</div>
if (isset($_POST['password'])) {
if ($_POST['password'] === $password05) {
header("Location: {$redirect05}");
exit;
}
elseif ($_POST['password'] === $password10) {
header("Location: {$redirect10}");
exit;
}
elseif ($_POST['password'] === $password20) {
header("Location: {$redirect20}");
exit;
}
elseif (strlen($_POST['password']) == 0) {
$alert = "Password cannot be empty.";
}
else {
$alert = "Password incorrect. Please try again.";
}
}
您可以使用header重定向
如何使用密码重定向到具有不同密码的不同页面。 回声丢失了一些东西,我想我应该添加一个数组。回声倍数如何回声... Grrr 我有 3 个密码,想使用这些密码重定向到 3 个不同的页面??
<?php
// Rename this file to config.php
$password05 = "fogy05";
$password10 = "fogy10";
$password20 = "fogy20";
$redirect05 = "download/05/index.html";
$redirect10 = "download/10/index.html";
$redirect20 = "download/20/index.html";
$require_https = true;
<?php
require_once("config.php");
if ($require_https && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on')) {
if(!headers_sent()) {
header("Status: 301 Moved Permanently");
header(sprintf(
'Location: https://%s%s',
$_SERVER['HTTP_HOST'],
$_SERVER['REQUEST_URI']
));
exit();
}
}
if (isset($_POST['password'])) {
if ($_POST['password'] === $password05) {
$success = true;
}
elseif (strlen($_POST['password05']) == 0) {
$alert = "Password cannot be empty.";
}
else {
$alert = "Password incorrect. Please try again.";
}
}
?>
<?php if ($success) { ?><meta http-equiv="refresh" content="3;URL=<?php echo $redirect ?>"><?php } ?>
<form class="form-signin" role="form" method="POST">
<?php if ($success) { ?>
<div class="alert alert-success" role="alert"><b>Code valide. Redirection...</b></div>
<?php } else { ?>
<?php if(isset($alert)) { ?>
<div class="alert alert-danger" role="alert"><b><?php echo $alert ?></b></div>
<?php } ?>
<h2 class="form-signin-heading">Veuillez entrer votre code</h2>
<input type="password" name="password" class="form-control" placeholder="Password" autocomplete="off" autofocus>
<button class="btn btn-lg btn-primary btn-block" type="submit">Go</button>
<?php } ?>
</form>
</div>
if (isset($_POST['password'])) {
if ($_POST['password'] === $password05) {
header("Location: {$redirect05}");
exit;
}
elseif ($_POST['password'] === $password10) {
header("Location: {$redirect10}");
exit;
}
elseif ($_POST['password'] === $password20) {
header("Location: {$redirect20}");
exit;
}
elseif (strlen($_POST['password']) == 0) {
$alert = "Password cannot be empty.";
}
else {
$alert = "Password incorrect. Please try again.";
}
}
您可以使用header重定向