0

我的登录代码如下:

<?php
session_start();
if (isset($_GET['action']) && $_GET['action']=='logout' ){
    session_destroy();
    header('location:index.php');
    exit();
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="css/login_style.css" />
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/>
<script src="js/jquery-1.6.min.js" type="text/javascript"></script>
<script src="js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>

<title>Login</title>
<style>
a:hover{
    cursor:pointer;
    text-decoration:none;
}
</style>
<script>
$(document).ready(function(){
    $("#myform").validationEngine();
});
</script>
</head>
<body>

<div class="form_controller">    
   <form action="index.php" method="post" id="myform" name="log">
    <table style=" margin-left: 164px; margin-top:86px;width: 292px;">
     <tr>
        <td style="color:#30a3b8;">Identifiant:</td><td><input type="text" name="text_username" class="validate[required]" style="border:1px solid #c9bbbb; height:20px; width:180px;"/></td>
     </tr>

   <tr>
    <td style="color:#30a3b8;"><br />Mot de passe: </td>
    <td><input type="password" name="text_password"  class="validate[required] TextInput" style=" margin-top:20px;border:1px solid #c9bbbb; height:20px; width:180px;"/><br /></td>
     </tr>

     </table>
    <table style="margin-top:50px; margin-left:197px;">
      <tr>
        <td></td>
        <td><input type="submit" name="tbn_submit" class="btnValider" value="Valider" style=""/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" class="btnValider" value="Annuler" /></td>
     </tr>
     </table>
     <table style="text-align:left; margin-top:-22px;">
         <tr>
            <td colspan="2"><a  href="register.php" style=" text-decoration:none; color:#30a3b8;" id="NewUser">Nouvel utilisateur?</a></td>
         </tr>
    </table>
        </form>
            <?php 
             include('include/encriptUrl.php');
             include ('include/connectdb.php');
                if(isset($_POST['tbn_submit'])){
                      $username = $_POST['text_username'];
                      $password = $_POST['text_password'];
                      $query = "SELECT * FROM tblusers WHERE `user_username`='".$username."' AND user_password='".$password."'";
                      $res = mysql_query($query) or die (mysql_error());
                      if($res){
                            if(mysql_num_rows($res)){
                                $user = mysql_fetch_assoc($res);
                                $_SESSION['username'] = $user['user_username'];
                                $_SESSION['password'] = $user['user_username'];
                                    if($user['user_possition'] == "Admin"){
                                        echo '<script type="text/javascript">window.location = "view_form.php"</script>';
                                    }
                                    else if($user['user_possition'] == "User"){
                                        echo '<script type="text/javascript">window.location = "view_edit_uid.php?uid='.encode5t($user['user_id']).'"</script>';                                        
                                    }                                       
                                    else if($user['user_possition'] == "R1"){
                                        echo '<script type="text/javascript">window.location = "view_form_res1.php"</script>';
                                    }
                                    else if($user['user_possition'] == "R2"){
                                        echo '<script type="text/javascript">window.location = "view_form_res2.php"</script>';
                                    }                               
                             } 
                             else {
                        echo '<script>alert("Invalid identifiant ou votre mot de passe.");</script>';             
                        }
                     }       
        }   
    ?>

 </div>
</body>
</html>

问题: 根据上面的代码,我在登录时使用会话来获取用户会话,它在本地运行良好,但是当我将其上传到服务器时,我收到了警告消息Warning: session_start() [function.session-start]: open(c:/wamp/tmp/sess_2m7odit3i1mprbmk1qg5b3j701, O_RDWR) failed: No such file or directory (2) in /homepages/0/d315362104/htdocs/demo/segpp/index.php on line 2Warning: Unknown: open(c:/wamp/tmp/sess_2m7odit3i1mprbmk1qg5b3j701, O_RDWR) failed: No such file or directory (2) in Unknown on line 0并且Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (c:/wamp/tmp) in Unknown on line 0。我不知道如何解决这个问题。

请任何人帮助我,谢谢。

4

2 回答 2

0

创建目录 c:/wamp/tmp/ 并确保它可由运行服务器的用户写入...

于 2012-11-21T04:26:27.637 回答
0

非常感谢您的回答,现在我用以下代码解决了它:

session_save_path('/tmp');
session_start();

所以我只是添加。比session_save_path('/tmp');它运作良好。

于 2012-11-22T03:08:12.183 回答