如何在php中显示用户图像?

vsmadaxz  于 2023-09-29  发布在  PHP
关注(0)|答案(2)|浏览(86)
if(isset($_REQUEST['sign_in'])) {
    if(!empty($_REQUEST['email']) && !empty($_REQUEST['password'])) {

        $sel = 'SELECT * FROM admin_login WHERE email="'.$_REQUEST["email"].'" AND password ="'.$_REQUEST["password"].'"';
        $result = $conn->query($sel);
        $data = mysqli_fetch_assoc($result);

        session_start();
        $_SESSION['user_id'] = $data['id'];
        $_SESSION['user_name'] = $data['firstname'];
        $_SESSION['user_email'] = $data['email'];
        $_SESSION['user_image'] = $data['image'];       

        if(mysqli_num_rows($result)==1) {
            header( 'location:http://localhost/prit/Dynamic/glance_design_dashboard/web/index.php');
        } else {
            $msg = 'Please Enter valid Email Or Password';
        }
    }
}

如何使用php获取图片?

<span class="prfil-img"><img src="images/<?php $_SESSION['user_image'];?>" alt=""> </span>
zzoitvuj

zzoitvuj1#

您可以执行以下操作:

<span class="prfil-img"><img src="images/<?php echo $_SESSION['user_image'];?>" alt=""> </span>

或:

<span class="prfil-img"><img src="images/<?= $_SESSION['user_image'];?>" alt=""> </span>
r8uurelv

r8uurelv2#

忘记在HTML代码中加入echo

<span class="prfil-img"><img src="images/<?php echo $_SESSION['user_image'];?>" alt=""> </span>

相关问题