删除会话

时间:2017-02-04 16:33:34

标签: php forms session

我遇到的问题是,当用户输入要注册的电子邮件时,代码会显示电子邮件已注册的输出,但它不会破坏会话,即使在其他用户进入后,同一消息也会继续显示并退出。我认为AND中缺少一些东西。 谢谢。

<?php
     if(!isset($_SESSION['email']) AND !isset($_SESSION['ID'])){
     ?>
     <div class="alert alert-success">
         The email has been registered. <strong>Welcome to Secret diary</strong>. Please login.
     </div>

    <?php
        session_destroy(); };
?>

这是另一个代码。

<?php

include 'dbh.php';
session_start();
$first=$_POST['fname'];
$last=$_POST['lname'];
$gender=$_POST['optradio'];
$email=$_POST['email'];
$pass=$_POST['pass'];
$conf=$_POST['conpass'];
$first5=substr(md5($pass), 0,5);
$sqli="SELECT * FROM user_reg WHERE email='$email'";

$result1=mysqli_query($conect,$sqli);

if (!$row=mysqli_fetch_assoc($result1)) {

$sql="INSERT INTO user_reg (fname,lname,gender,email,password)         VALUES('$first','$last','$gender','$email','$encry')";
$result=mysqli_query($conect,$sql);

}else{

$_SESSION['email']=$row['email'];

};


header("Location:index.html");
$last5=substr(md5($pass), 15,5);
$encry=$first5.$last5;
         ?>

1 个答案:

答案 0 :(得分:0)

尝试使用此代码取消会话中的值

<?php unset($_SESSION['email']); unset($_SESSION['ID']); ?>