douzhuo2002 2012-05-09 21:16
浏览 39
已采纳

不使用子ID导航

i am just setting up the general template for my website and the little bit of php that i am doing is to just get the users id from page to page, in other words i want the user while logged in to go from page to page, without using the sub id in the header of user_id=3 for example, and then using the get function to get it and display their information, i want to be able to do it without that.

Here is my code but i keep getting the error

Notice: Undefined index: user_id in C:\xampp\htdocs\Arken\profile.php on line 7

LOGIN CODE (not all of it of course, just the bit for setting the sessions tuff)

// Create session var for their raw id
                $user_id = $row["user_id"];   
                $_SESSION['user_id'] = $user_id;
                // Create the idx session var
                $_SESSION['idx'] = base64_encode("g4p3h9xfn8sq03hs2234$id");
                // Create session var for their username
                $login_username = $row["login_username"];
                $_SESSION['login_username'] = $login_username;
                // Create session var for their password
                $login_userpass = $row["login_password"];
                $_SESSION['login_userpass'] = $login_userpass;

PHP for each page

    session_start();

$user_id = "";


if ($_GET['user_id']) {

     $user_id = $_GET['user_id'];

} else if (isset($_SESSION['user_id'])) {

     $user_id = $_SESSION['user_id'];

} else {

   include_once "index.php";
   exit();
}
include 'connect_to_mysql.php';

Thanks for your help

  • 写回答

2条回答 默认 最新

  • dongliuxia9495 2012-05-09 21:19
    关注

    I am assuming line 7 is

    if ($_GET['user_id']) {
    

    Try making sure it's set before using it:

    if (isset($_GET['user_id'])) {
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度