Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么我的$u帖子[';用户名';]不是每次在我的某个会话上都刷新?_Php_Html_Sql_Session_Post - Fatal编程技术网

Php 为什么我的$u帖子[';用户名';]不是每次在我的某个会话上都刷新?

Php 为什么我的$u帖子[';用户名';]不是每次在我的某个会话上都刷新?,php,html,sql,session,post,Php,Html,Sql,Session,Post,我在这里有两个会话,在两个相关查询中都使用$POST['username'],但在$\u会话['address']上,它仍然使用我的旧$POST['username'],因此它不会刷新 <?php include_once'config/connect.php'; //database connection if($_POST['submit']) { $retrieve = mysql_query("SELECT username,password FROM iangado

我在这里有两个会话,在两个相关查询中都使用$POST['username'],但在$\u会话['address']上,它仍然使用我的旧$POST['username'],因此它不会刷新

<?php

include_once'config/connect.php'; //database connection

if($_POST['submit']) {

    $retrieve = mysql_query("SELECT username,password FROM iangadot_user
                             WHERE username='".$_POST['username']."' AND password='".md5($_POST['password'])."' ");
    $address = mysql_query("SELECT location FROM venue
                            WHERE vid in (select vid from  user_venue where id in (select id from iangadot_user where username='".$_POST['username']."' )) ");
    if(mysql_num_rows($retrieve)) {

        //redirect to your client page...
        //SET YOUR session
        $_SESSION['username_profile'] = $_POST['username'];
        header("Location: clientpag.php");


    } else {
        echo "<script language=javascript>alert('Wrong username or password')</script>";
        //header("Location: ./?errorlogged=err");


    }
    if(mysql_num_rows($address)) {

        $row = mysql_fetch_assoc($address);
        $_SESSION['address'] = $row['location'];

        header("Location: clientpag.php");

    }

}


?>

您需要在设置或使用会话的每个文件中启动会话

在脚本开头:
session_start()

您需要在设置或使用会话的每个文件中启动会话
在脚本开头:
session_start()

在php文件中添加会话开始:

<?php

include_once'config/connect.php'; //database connection
session_start();

在php文件中添加会话开始:

<?php

include_once'config/connect.php'; //database connection
session_start();

您有会话_start()吗;在您的第一个文件中?不在我的php文件@AwladLitonAdd session_start()中;在php文件的顶部。如果它执行$_SESSION['address']=$row['location'],那么它应该在这之后工作;行正确您的问题有点不清楚,但是您的第二个查询似乎没有返回任何行,因此会话变量没有更新。您有会话_start()吗;在您的第一个文件中?不在我的php文件@AwladLitonAdd session_start()中;在php文件的顶部。如果它执行$_SESSION['address']=$row['location'],那么它应该在这之后工作;行正确您的问题有点不清楚,但是您的第二个查询似乎没有返回任何行,因此会话变量没有更新。我只是尝试了这个,但没有解决问题。你看,我的第一个会话每次都会更新,但第二个会话不会。你说的第一个和第二个会话是什么意思??
$\u会话['username\u profile']=$\u POST['username'];标题(“位置:clientpag.php”):现在转到另一个页面,因此代码的其余部分不会执行?我只是尝试了这个,但没有解决问题。你看,我的第一个会话每次都会更新,但第二个会话不会。你说的第一个和第二个会话是什么意思??
$\u会话['username\u profile']=$\u POST['username'];标题(“位置:clientpag.php”):在这里您转到另一个页面,因此代码的其余部分不会执行?