在与ID的PHP会话的一些问题?

时间:2019-04-30 19:59:01

标签: php

当我以用户身份登录并通过会话ID时,在wamp的站点中无法激活,但是当我上传到000webhost时,我无法解决我的问题和我的代码

index.php

<?php   
session_start();

include 'connection.php';

 ?>

<!DOCTYPE html>
<html lang="en">
<head>
<title>Tekkadan</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Baloo">

<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<style>
body {
  font-family: 'Baloo', cursive !important;
}
h3{
   font-family: 'Baloo', cursive !important;
}
b{
     font-family: 'Baloo', cursive !important;

}
.mySlides {display: none}
</style>
</head>
<body>
<!-- Navbar -->
<div class="w3-top">
  <div class="w3-bar w3-black w3-card">
    <a class="w3-bar-item w3-button w3-padding-large w3-hide-medium w3-hide-large w3-right" href="javascript:void(0)" onclick="myFunction()" title="Toggle Navigation Menu" ><img src="sidr.png" style="height: 30px;width: 30px;background-color: #841818;"></i></a>
    <a href="index.php" class="w3-bar-item w3-button w3-padding-large">HOME</a>
    <?php  if(empty($_SESSION['sess_guild'])){?>
    <a href="login.php" class="w3-bar-item w3-button w3-padding-large w3-hide-small">تسجيل دخول</a>
  <?php }else{?>
        <a href="giny.php" class="w3-bar-item w3-button w3-padding-large w3-hide-small">الجيني</a>

    <a href="avatar.php?id=<?php echo ($_SESSION['sess_id']); ?>" class="w3-bar-item w3-button w3-padding-large w3-hide-small">البروفايل</a>
    <a href="logout.php" class="w3-bar-item w3-button w3-padding-large w3-hide-small">تسجيل خروج</a>
  <?php } ?>
  <?php if(!empty($_SESSION['sess_auth'])){
   if ($_SESSION['sess_auth']=="admin" || $_SESSION['sess_auth']=="co" || $_SESSION['sess_auth']=="giny" || $_SESSION['sess_auth']=="warning") {?>
    <a href="admin.php" class="w3-bar-item w3-button w3-padding-large w3-hide-small">الادمن</a>
  <?php }} ?>

  </div>
</div>

<!-- Navbar on small screens (remove the onclick attribute if you want the navbar to always show on top of the content when clicking on the links) -->
<div id="navDemo" class="w3-bar-block w3-black w3-hide w3-hide-large w3-hide-medium w3-top" style="margin-top:46px">
    <a href="index.php" class="w3-bar-item w3-button w3-padding-large">HOME</a>

      <?php  if(empty($_SESSION['sess_guild'])){?>
  <a href="login.php" class="w3-bar-item w3-button w3-padding-large">تسجيل دخول</a>
    <?php }else{?>
        <a href="giny.php" class="w3-bar-item w3-button w3-padding-large">الجيني</a>
        <a href="admin.php" class="w3-bar-item w3-button w3-padding-large">الادمن</a>

        <a href="logout.php" class="w3-bar-item w3-button w3-padding-large">تسجيل خروج</a>
        <a href="avatar?id=<?php echo ($_SESSION['sess_id']); ?>" class="w3-bar-item w3-button w3-padding-large">البروفايل</a>

<?php } ?>
</div>

login.php的过程

<?php 
include 'connection.php';
session_start();
if(empty($_SESSION['sess_guild'])){

    $user=$_POST['user'];
    $pass=$_POST['pass'];
    $sql = mysqli_query($conn,"SELECT * FROM users WHERE user ='".$user."' AND pass='".$pass."' ");
    $row = mysqli_fetch_assoc($sql);
    $numrows = mysqli_num_rows($sql);
    if ($numrows == 0) {
        echo "invaild pass or user";
    }else{
        $_SESSION['sess_user']=$row[user];
        $_SESSION['sess_guild']=$row[guild];
        $_SESSION['sess_auth']=$row[authiroty];

  if ($_SESSION['sess_guild'] == "forever") {
    $sqla="SELECT * FROM forever WHERE user='".$_SESSION['sess_user']."'";
    $sqlc="SELECT COUNT(id) FROM forever ";
    $forever=mysqli_query($conn,$sqlc);
    $iduser=mysqli_query($conn,$sqla);
    $rowuser = mysqli_fetch_assoc($iduser);   
    $_SESSION['sess_id']= "$rowuser[id]";
    $_SESSION['sess_giny']= "$rowuser[giny]";
    }


    header('Location:index.php');
}elseif(!empty($_SESSION['sess_guild'])){
    echo "nooooo";
}


?>

用户点击个人资料时我想要

<a href="avatar?id=<?php echo ($_SESSION['sess_id']); ?>" class="w3-bar-item w3-button w3-padding-large">البروفايل</a>

单击此链接时,我需要链接从进程获取sess_id 还是我想要,如果点击个人资料,则获得该https://stackoverflow.com/users/11227805/rashed-kamal

这样的个人资料的链接

0 个答案:

没有答案