我制作了一个登录脚本,它是索引:
<?php
session_start()
if(isset($_POST['username'])&&!empty($_POST['username'])){
header("location:login.php");
}
echo "selamat datang ".$_SESSION['username'];
?>
<br/><br/><br/>
<a href="logout.php">Logout</a>
当我尝试它时,它会告诉我:
有人知道吗?解析错误:语法错误,意外&#39;如果&#39; (T_IF)
答案 0 :(得分:0)
空格不合适,请在;
session_start
<?php
session_start();
if(isset($_POST['username']) && !empty($_POST['username'])){
header("location:login.php");
}
echo "selamat datang ".$_SESSION['username'];
?>
<br/><br/><br/>
<a href="logout.php">Logout</a>
答案 1 :(得分:0)
MISSING ; AFTER_start
<?php
session_start();
if(isset($_POST['username'])&&!empty($_POST['username'])){
header("location:login.php");
}
echo "selamat datang ".$_SESSION['username'];
?>
<br/><br/><br/>
<a href="logout.php">Logout</a>
答案 2 :(得分:0)
试试这个......
<?php
session_start(); //miss semicolon
if(isset($_POST['username'])&&!empty($_POST['username'])){
header("location:login.php");
}
echo "selamat datang ".$_SESSION['username'];
?>
<br/><br/><br/>
<a href="logout.php">Logout</a>