会话变量未传递到下一页

时间:2016-12-15 08:20:02

标签: php

index.php

 <?php
    session_start();

    ?>
    <!DOCTYPE HTML>
    <html>
    <head>


    <meta http-equiv="Content-Type"content="text/html;charset=UTF-8">
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery- .min.js"
    type="text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"     type="text/javascript"></script>
    <link href="style1.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen and (max-width: 360px)" href="portrait.css">
    <link rel="stylesheet" type="text/css" media="screen and (min-width: 361px) and (max-width: 480px)" href="landscape.css">
    <link rel="stylesheet" type="text/css" media="screen and (min-width: 481px)" href="desktop.css">


    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
rel="Stylesheet"type="text/css"/>
</head>
<body>
<div id="container">
  <div id="banner">

  </div>

  <div class="clear"></div>
</br></br></br>

    <br /><br /><br /><br />
<?php    echo $reg; ?>
<form action="login.php" method="post" enctype="multipart/form-data">
        <table border="2" align="center" width="400px" cellspacing="0" cellpadding="2" style="border-color:#FFF;">
            <tr>
                <td align="center" style="background:#4CAF50; font-weight:bold;" colspan="2">लॉगिन</td>
            </tr>
            <tr>
                <td>यूजर का नाम: </td>
                <td><input type="text" name="name" size="25"></td>
            </tr>
            <tr>
                <td>पासवर्ड:</td>
                <td><input type="password" name="password" size="25"></td>
            </tr>
            <tr>
                <td align="center" colspan="2"><input type="Submit" value="submit"></td>
            </tr>
        </table>
    </form>
    </br></br></br></br></br></br></br></br></br>

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

2.login.php

<?php
session_start();
$name=$_REQUEST['name'];
$password=$_REQUEST['password'];
if($name=='admin' && $password=='admin')
{
    session_start();
    $_SESSION['sid']=session_id();
header('location:template.php');
}
else
{
header('location:index.php');

$_SESSION['reg']="<font color=#800000; size=4>Invalid User Name and Password. Please Enter Again.</font>";
}
?>
  1. 的template.php

                        

    <meta http-equiv="Content-Type"content="text/html;charset=UTF-8">
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
    type="text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
    <link href="style1.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen and (max-width: 360px)" href="portrait.css">
    <link rel="stylesheet" type="text/css" media="screen and (min-width: 361px) and (max-width: 480px)" href="landscape.css">
    <link rel="stylesheet" type="text/css" media="screen and (min-width: 481px)" href="desktop.css">
    
    
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
    rel="Stylesheet"type="text/css"/>
    </head>
    <body>
    <div id="container">
    
      <div id="navbar">
        <ul>
          <li align="center"><a href="template.php">मुख पृष्ठ </a></li>
       <li align="center"><a href="ftender.php">निविदा</a></li>
       <li align="center"><a href="workorderlogin.php">कार्य आदेश </a></li>
       <li align="center"><a href="salary.php">वेतन</a></li>
       <li align="center"><a href="shoprent.php">दुकान </a></li>
       <li align="center"><a href="stock.php">स्टॉक</a></li>
       <li align="center"><a href="misleneous.php">विविध</a></li>
         <li align="center"><a href="account.php">लेखा-जोखा</a></li>
      <li align="center"><a href="index.php">लोग आउट</a></li>
    </ul>
      </div>
      <div class="clear"></div>
    
      <div id="content">
      <br/><br/><br/><br/>
        <center><img  src=images/looks-solid.jpg width=500 height=250  alt=Edit /></center> 
         </br> </br><br/><br/>
    
        </div>
    
      <div id="bottom"></div>
      <div class="clear"></div>
     <?php }
      else
        {
            header("location:index.php");
        }
     ?>
    
    </div>
    </body>
    </html>
    
  2. logout.php

    session_start(); session_destroy(); setcookie(PHPSESSID,session_id(),time()-1); header('location:index.php'); ?&GT;
  3. 我的会话不是在线项目,但在localhost上,它正常工作。我希望在退出后,按下后​​退按钮它不应该显示页面,它在登录后显示。

0 个答案:

没有答案
相关问题