PHP header(Location: …): Force URL change in address bar

后端 未结 14 1648
失恋的感觉
失恋的感觉 2020-11-28 08:10

I\'m currently working on a mobile site with authentication using PHP sessions with a database. I have a login page with a form that goes to server_login.php

14条回答
  •  旧时难觅i
    2020-11-28 08:24

    // Register user's name and ID

    if ((!isset($_SESSION['name'])) && (!isset($_SESSION['user_id'])))  {
        $row = mysql_fetch_assoc($login_result);
        $_SESSION['name'] = $row['name'];
        $_SESSION['user_id'] = $row['user_id'];
    }
    
    header("Location: http://localhost:8080/meet2eat/index.php");
    

    change to

    // Register user's name and ID

    if ((!isset($_SESSION['name'])) && (!isset($_SESSION['user_id'])))  {
        $row = mysql_fetch_assoc($login_result);
        $_SESSION['name'] = $row['name'];
        $_SESSION['user_id'] = $row['user_id'];
    header("Location: http://localhost:8080/meet2eat/index.php");
    }
    

提交回复
热议问题