你好伙伴们,我不知道为什么PHP会向我投掷,我相信我已经在我的文本中定义了它,但PHP认为不然。我收到以下错误
注意:未定义的变量:第23行的C:\ xampp \ htdocs \ wd1_vtec_0100348514 \ index.php中的消息
注意:未定义的变量:第32行的C:\ xampp \ htdocs \ wd1_vtec_0100348514 \ index.php中的消息
这是我的代码页面index.php ..
<div class="masthead">
<div class="sliding-car">
<img src="main/img/subaru.jpg" alt="Subaru">
</div>
</div>
<hr>
<div class="jumbotron">
<p class="lead">Enter your Username & Password</p>
<?php if(isset($_GET['message']))
//Alert messages based on integers
if($message == 1) {
echo '
<div class="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Invalid username or password</strong>
</div>
';
}
else if($message == 2) {
echo '
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>You have successfully logged out! </strong>
</div>
';
}
?>
<form action="auth_check.php" method="post" class="form-signin">
<h2 class="form-signin-heading">Please sign in</h2>
<input name="username" type="text" class="input-block-level" placeholder="Username">
<input name="password" type="password" class="input-block-level" placeholder="Password">
<button class="btn btn-large btn-primary" type="submit">Sign in</button>
</form>
<a class="btn btn-large btn-success" href="register.php">Register New User</a>
</div>
<div class="sliding-car">
<img src="main/img/subaruswag.png" alt="Subaru">
</div>
任何帮助都会有很大帮助!感谢!!!
答案 0 :(得分:3)
您忘了将$_GET['message']
分配给$message
变量。
$message = $_GET['message'];
答案 1 :(得分:0)
使用$ _GET [&#39; message&#39;]更改$ message或设置变量$ message。示例:$ message = $ _GET [&#39; message&#39;]