$ _SESSION不会设置

时间:2015-04-28 23:28:42

标签: php session

我已经花了几个小时而且在我的生命中,$ _SESSION不会设置。如果我直接对它应用一个值就行了。我已在表单中重命名['用户名']并尝试了各种组合。

<?php

//数据安全检查ip

// include&#39; functions / getclientip.php&#39;;

如果(isset($ _ POST [&#39;提交&#39;])){

                                // get post data from login form
                                $getuser = trim(htmlentities($_POST['username']));
                                $getpass = trim(htmlentities(md5($_POST['password'])));

                                if ($getuser&&$getpass){          //check to see if both entered
                                       require('admin_connect.php');   //connect to db

                                        //check db for user match
                                        $query = mysql_query("SELECT * FROM users WHERE username='$getuser'");
                                        $numrows = mysql_num_rows($query);  

                                                if($numrows !== 0){     //check for number of rows

                                                    while ($row = mysql_fetch_assoc($query)) {
                                                              $dbid = $row['id'];
                                                              $dbuser = $row['username'];
                                                              $dbpass = $row['password'];
                                                              $dbstatus = $row['status'];

                                                              $active = "active"; // set to match required status

                                                              if(($getuser === $dbuser)&&($getpass === $dbpass)&&($active === $dbstatus)){   //check for match from POST to db

                                                                  //session_start();
                                                                  $client=$_SESSION['myusername'];

                                                                  // $client=$_SESSION['username']; 

                                                                  //relabel url and send to new page
                                                                      $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
                                                                            if((substr($url, -1)=='/') OR (substr($url, -1) == '\\')) {
                                                                                  $url = substr ($url, 0, -1);
                                                                              }
                                                                      $url .='/loader.php';

                                                                       // header("location: $url");

                                                                        echo $client;
                                                                          exit(); 

                                                              }//check for match from POST to db

                                                    } // mysql_fetch_assoc


                                                }// check number of rows


                                }   // check to see if username and password entered

} // isset submit
?&GT;

0 个答案:

没有答案