我正在创建我的登录页面但是当我在我的网站托管网站上传时它显示错误....... PLZ帮我纠正这个.........
<?php
session_start(); $username = $password = $userError = $passError = '';
if(isset($_POST['sub'])){
$username = $_POST['username']; $password = $_POST['password'];
if($username === '9155499248' && $password === 'Ben 10'){
$_SESSION['login'] = true; header('LOCATION:congratulation.php'); die();
}
if($username !== '9155499248')$userError = 'Invalid Username';
if($password !== 'Ben 10')$passError = 'Invalid Password';
}
echo "<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='content-type' content='text/html;charset=utf-8' />
<title>Login</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css"/>
<script src="js/prefixfree.min.js"></script>
</head>
<body>
<div class="login">
<h1><b>Login</b></h1>
<form name='input' action='{$_SERVER['PHP_SELF']}' method='post'>
<label for='username'></label><input type='text' value='$username' id='username' name='username' />
<div class='error'>$userError</div>
<label for='password'></label><input type='password' value='$password' id='password' name='password' />
<div class='error'>$passError</div>
<button type="submit" class="btn btn-primary btn-block btn-large" name="submit">Let me in.</button>
</form>
</div>
<script src="js/index.js"></script>
</body>
</html>
错误的屏幕截图如下所示...... This is image
答案 0 :(得分:2)
试试这个
此示例仅使用"
转义\
,因为您已使用它来创建字符串。
<?php
session_start(); $username = $password = $userError = $passError = '';
if(isset($_POST['sub'])){
$username = $_POST['username']; $password = $_POST['password'];
if($username === '9155499248' && $password === 'Ben 10'){
$_SESSION['login'] = true; header('LOCATION:congratulation.php'); die();
}
if($username !== '9155499248')$userError = 'Invalid Username';
if($password !== 'Ben 10')$passError = 'Invalid Password';
}
echo "<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='content-type' content='text/html;charset=utf-8' />
<title>Login</title>
<link rel=\"stylesheet\" href=\"css/normalize.css\">
<link rel=\"stylesheet\" href=\"css/style.css\"/>
<script src=\"js/prefixfree.min.js\"></script>
</head>
<body>
<div class=\"login\">
<h1><b>Login</b></h1>
<form name='input' action='{$_SERVER['PHP_SELF']}' method='post'>
<label for='username'></label><input type='text' value='$username' id='username' name='username' />
<div class='error'>$userError</div>
<label for='password'></label><input type='password' value='$password' id='password' name='password' />
<div class='error'>$passError</div>
<button type=\"submit\" class=\"btn btn-primary btn-block btn-large\" name=\"submit\">Let me in.</button>
</form>
</div>
<script src=\"js/index.js\"></script>
</body>
</html>";