当我登录会话时只读取 php 中的一个字符

将变量分配给 $_SESSion。当我回显那个会话时,它显示了一个字符的例子


$name="abcd"; 这个回声结果是 abcd。$_SESSION['abcd'] = $name; 此回声结果仅为“a”字符


 <?php

include("dbConnect.php");

if (isset($_POST['username'])) {

    $name = $_POST['username'];

    $_SESSION = $name;

}

if (isset($_POST['password'])) {

    $password = $_POST['password'];

    $_SESSION = $password;

}


try { 


    $conn = connect(); 


    $sql="SELECT id,employee_name,email,phone,password,image,created_on FROM handel WHERE employee_name = '$name' AND password = '$password' ";

    $result=mysqli_query($conn,$sql);


    close($conn);


} catch (Exception $e) { 

    //echo $e->errorMessage(); 

    close($conn);

    errorPage();

}

    // Associative array

    $data = mysqli_fetch_array($result,MYSQLI_ASSOC);

    print_r($data);

    echo $operatorId = $data['id'];

    echo $_SESSION['employee_name'] = $data['employee_name'];

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

    $_SESSION['phone'] = $data['phone'];

    $_SESSION['password']=$data['password'];

    $_SESSION['image']=$data['image'];

    $_SESSION['created_on']=$data['created_on'];

 ?>

$name="abcd"; 这个回声结果是 abcd。$_SESSION['abcd'] = $name; 这个回声结果也显示'abcd'


胡子哥哥
浏览 121回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP