我在本地主機上的工作,並試圖創建一個登錄系統,但我的會議沒有啓動,這是我的PHP代碼PHP會話沒有啓動
if(isset($_POST['_submit'])){
session_start();
if(empty($_POST['_email']) || empty($_POST['_password'])){
echo "<script>window.alert('Invalid User EMAIL or PASSWORD!')</script>";
}
else{
$email = $_POST['_email'];
$password = $_POST['_password'];
$select_user = "SELECT email,password FROM signup WHERE email='$email' AND password='$password'";
$query = mysqli_query($conn,$select_user);
$rows = mysqli_num_rows($query);
if($rows>0){
$_SESSION['user_email'] = $email;
header('Location: ../index.php');
}
else{
echo "<script>window.alert('Invalid User EMAIL or PASSWORD!')</script>";
}
}
}
和會話開始後,我想在HTML代碼來改變,這裏是我的代碼
<?php if(!empty($_SESSION['user_email'])){ ?>
<li><a href="#">Logout</a></li>
<?php } else { ?>
<li><a href="login/index.php">Login</a></li>
<li><a href="signUp/index.php">Sign Up</a></li>
<?php } ?>
這裏是登錄系統的我的HTML代碼
<div class="outside">
<form class="form-horizontal" role="form" method="post">
<div class="form-group">
<label class="control-label col-sm-3 glyphicon glyphicon-user" for="email"></label>
<div class="control-label col-sm-8">
<input type="_email" name="_email" class="form-control" id="email" placeholder="Enter Email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3 glyphicon glyphicon-lock" for="password"></label>
<div class="control-label col-sm-8">
<input type="password" name="_password" class="form-control" id="password" placeholder="Enter Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-3">
<button name="_submit" type="submit" class="btn btn-default" >Login</button>
</div>
</div>
</form>
<p>Not a User? <a href="../signUp/index.php">Sign Up</a></p>
</div>
謝謝,
請張貼您的html代碼以及...完成 –
登錄系統的html代碼? –
是的請...完成 –