O
O
Ocervi2015-07-13 13:34:52
Audio
Ocervi, 2015-07-13 13:34:52

How to correctly specify a link using sessions?

<?php
session_start();

include ("basa.php");




if (isset($_COOKIE['auto']) and isset($_COOKIE['login']) and isset($_COOKIE['password']))
{//если есть необходимые переменные
  if ($_COOKIE['auto'] == 'yes') { 
      $_SESSION['password']=strrev(md5($_COOKIE['password']))."b3p6f"; 
      $_SESSION['login']=$_COOKIE['login'];
      $_SESSION['id']=$_COOKIE['id'];
    }	
  }

if (!empty($_SESSION['login']) and !empty($_SESSION['password']))
{
$login = $_SESSION['login'];
$password = $_SESSION['password'];
$result = mysql_query("SELECT id,avatar FROM users WHERE login='$login' AND password='$password' AND activation='1'",$db); 
$myrow = mysql_fetch_array($result);
//извлекаем нужные данные о пользователе
}
$query = mysql_query("SELECT mone FROM users WHERE login='$login' AND password='$password' AND activation='1'");
$row = mysql_fetch_array($query);
$_SESSION['mon']=$row[mone];
?>
<html>
<head>
<title>Главная страница</title>
<link rel="stylesheet" href="css/bootstrap.css">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h2>Главная страница</h2>

<nav class="navbar navbar-default">
  <div class="container-fluid"> 
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
      <a class="navbar-brand" href="#">Brand</a> </div>
    



================================================ТУТ====================================================
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li ><a href="page.php?id=$_SESSION[id]">Моя страница</a> </li>==========================================
        <li><a href="index.php">Главная</a> </li>
    <li><a href="all_users.php">Список пользователей</a> </li>
    <li><a href="group.php">Группы</a> </li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="exit.php">выход</a> </li>
          <ul class="dropdown-menu" role="menu">
            <li><a href="#">Action</a> </li>
            <li><a href="#">Another action</a> </li>
            <li><a href="#">Something else here</a> </li>
            <li class="divider"></li>
            <li><a href="#">Separated link</a> </li>
          </ul>
              </ul>
    </div>
    <!-- /.navbar-collapse --> 
  </div>
  <!-- /.container-fluid --> 
</nav>

You need to add this link <="page.php?id=$_SESSION[id]">My page, but only www.page.php?id=$_SESSION[id] appears in the address bar

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2015-07-13
@Ocervi

<a href="page.php?id=<?= $_SESSION['id']; ?>">Моя страница</a>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question