一直出现这个问题,有大佬能指点一下吗?哪里有问题
源码如下
<meta charset="utf-8"><?php if (isset($_POST['userName'])) { if (!empty($_POST['userName'])&&!empty($_POST['passWord'])) { #判断输入的用户名和密码是否为空 if ($_POST['userName'] == "zzh" && $_POST['passWord'] == "123") {#判断输入的用户名密码是否为确定的值 if (setcookie("name","zzh")) {//如果是制定值,则下发cookie echo "登录成功,欢迎您访问!<a href='./index.php'>返回首页</a>"; }else{ echo "cookie下发失败!"; } }else{ echo "用户名或密码错误!<a href='./login.php'>请重新登录!</a>"; } } else{ echo "用户名或密码错误!<a href='./login.php'>请重新登录!</a>"; } }else{ //代码后面的代码是HTML的 $htm = <<<HTML <html><head> <title>登录页面</title> <meta charset="utf-8"></head><body> <!--登录表单--> <form action="./login.php" method="post" target="_blank"> 用户名:<input type="text" name="userName"><br> 密码:<input type="password" name="passWord"><br> <input type="submit" name="userSubmit" value="登录"> <!--提交按钮--> </form></body></html>HTML; //代表HTML结束 echo $htm; }?>
谢谢大佬!
<<<后面加个空格,结尾的HTML 另起一行就可以了。
if (isset($_POST['userName'])) { if (!empty($_POST['userName'])&&!empty($_POST['passWord'])) { if ($_POST['userName'] == "zzh" && $_POST['passWord'] == "123") { if (setcookie("name","zzh")) { echo "登录成功,欢迎您访问!<a href='./index.php'>返回首页</a>"; }else{ echo "cookie下发失败!"; } }else{ echo "用户名或密码错误!<a href='./login.php'>请重新登录!</a>"; } } else{ echo "用户名或密码错误!<a href='./login.php'>请重新登录!</a>"; }}else{ $htm = <<< HTML <head> <title>登录页面</title> <meta charset="utf-8"> </head> <body> <form action="./login.php" method="post" target="_blank"> 用户名:<input type="text" name="userName"><br> 密码:<input type="password" name="passWord"><br> <input type="submit" name="userSubmit" value="登录"> </form> </body> </html> HTML; echo $htm;}
<<<后面加个空格试一下