仅在用户未登录时显示注销(show logout only if user is not logged in)
我有一个导航栏的PHP脚本。 这是我所拥有的,但它一直显示一个空白页面,如果我删除链接并放置重定向,而不是任何问题。
<?php session_start(); if (!isset($_SESSION['id'])) { echo "<a href='create.php'>Create</a>" echo "<a href='search.php'>Search</a>" } else { echo "<a href='logout.php'>Logout</a>" echo "<a href='create.php'>Create</a>" echo "<a href='search.php'>Search</a>" } ?>I have a php script for the navigation bar. This is what I have but it keeps showing a blank page, if I remove the links and put a redirect instead it works without any problems.
<?php session_start(); if (!isset($_SESSION['id'])) { echo "<a href='create.php'>Create</a>" echo "<a href='search.php'>Search</a>" } else { echo "<a href='logout.php'>Logout</a>" echo "<a href='create.php'>Create</a>" echo "<a href='search.php'>Search</a>" } ?>最满意答案
你错过了所有的分号
echo "<a href='create.php'>Create</a>"; <--- echo "<a href='search.php'>Search</a>"; <---- } else { echo "<a href='logout.php'>Logout</a>"; <--- echo "<a href='create.php'>Create</a>"; <--- echo "<a href='search.php'>Search</a>"; <---You're missing all the semicolons
echo "<a href='create.php'>Create</a>"; <--- echo "<a href='search.php'>Search</a>"; <---- } else { echo "<a href='logout.php'>Logout</a>"; <--- echo "<a href='create.php'>Create</a>"; <--- echo "<a href='search.php'>Search</a>"; <---仅在用户未登录时显示注销(show logout only if user is not logged in)我有一个导航栏的PHP脚本。 这是我所拥有的,但它一直显示一个空白页面,如果我删除链接并放置重定向,而不是任何问题。
<?php session_start(); if (!isset($_SESSION['id'])) { echo "<a href='create.php'>Create</a>" echo "<a href='search.php'>Search</a>" } else { echo "<a href='logout.php'>Logout</a>" echo "<a href='create.php'>Create</a>" echo "<a href='search.php'>Search</a>" } ?>I have a php script for the navigation bar. This is what I have but it keeps showing a blank page, if I remove the links and put a redirect instead it works without any problems.
<?php session_start(); if (!isset($_SESSION['id'])) { echo "<a href='create.php'>Create</a>" echo "<a href='search.php'>Search</a>" } else { echo "<a href='logout.php'>Logout</a>" echo "<a href='create.php'>Create</a>" echo "<a href='search.php'>Search</a>" } ?>最满意答案
你错过了所有的分号
echo "<a href='create.php'>Create</a>"; <--- echo "<a href='search.php'>Search</a>"; <---- } else { echo "<a href='logout.php'>Logout</a>"; <--- echo "<a href='create.php'>Create</a>"; <--- echo "<a href='search.php'>Search</a>"; <---You're missing all the semicolons
echo "<a href='create.php'>Create</a>"; <--- echo "<a href='search.php'>Search</a>"; <---- } else { echo "<a href='logout.php'>Logout</a>"; <--- echo "<a href='create.php'>Create</a>"; <--- echo "<a href='search.php'>Search</a>"; <---
发布评论