会话存在时标签更改

时间:2014-05-13 15:15:49

标签: php session

我正在建立一个销售网站,我需要客户帐户,如果登录完成

    session_start();
    include ("connbd.php"); where ligabd is the connection to the database
    $query = "SELECT * FROM clientes WHERE utilizador = '".$user."' AND pass = '".$pass."'";
    $result = mysqli_query($connbd,$query);
    $count = mysqli_num_rows($result);
    if (!$result) {

    $_SESSION['user']=$user;
    $_SESSION['password']=$pass;
    header("location:index.php");
}

现在在索引页面我有标签登录和注册,我的问题是如何使用:

if isset $_SESSION['user']
label register="" & label login =""
labeluser=$_SESSION['user']

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

session_start();放在代码的第一行

here is tutorial

享受:)

答案 1 :(得分:1)

<?php
    session_start();

      if (isset $_SESSION['user']){
           $labelregister="";
           $labellogin ="";
           $labeluser=$_SESSION['user'];
      }
?>