帮忙看一下这段登录跳转的php代码如何修改

问题描述

帮忙看一下这段登录跳转的php代码如何修改 50C
 session_start();if(isset($_POST['password']) && $_POST['password'] == 'admin'){    $_SESSION['ok'] = 1;    header('location:index.php');}if(!isset($_SESSION['ok'])){    exit('        <form method=""post"">            密码:<input type=""password"" name=""password"" value=""admin"" />            <input type=""submit"" value=""登陆""  />        </form>    ');}

这段php代码 跳转到index.php需要输入密码访问,如果密码输入对了 再次登录的时候就不用输入密码了 但是问题 虽然不用输入密码点击登录了,但是页面打开还是当前页面,而不是index.php 请问如何修改呢

解决方案

 session_start();if(isset($_POST['password']) && $_POST['password'] == 'admin'){    $_SESSION['ok'] = 1;    header('location:index.php');}if(!isset($_SESSION['ok'])){    exit('        <form method=""post"">            密码:<input type=""password"" name=""password"" value=""admin"" />            <input type=""submit"" value=""登陆""  />        </form>    ');}else header('location:index.php');//////////

解决方案二:
#//index.php
<?php

session_start();
if(!isset($_SESSION['ok'])){
header('location:login.php');
}

echo ""hello world!"";
?>

#//login.php

<?php
session_start();
if(isset($_SESSION['ok'])||(isset($_POST['password']) && $_POST['password'] == 'admin')){
$_SESSION['ok'] = 1;
header('location:index.php');

}
if(!isset($_SESSION['ok'])){
exit('

密码:

');
}
?> 解决方案三:
#//login.php
<?php
session_start();
if(isset($_SESSION['ok'])||(isset($_POST['password']) && $_POST['password'] == 'admin')){
$_SESSION['ok'] = 1;
header('location:index.php');

}
if(!isset($_SESSION['ok'])){
exit('

密码:

');
}
?> 解决方案四:
上面exit中内容不变,我提交完之后内容没有了,抱歉;

时间: 2024-08-18 17:52:17

帮忙看一下这段登录跳转的php代码如何修改的相关文章

帮忙看下这段代码,为啥那个afafafa没有打印出来?

问题描述 帮忙看下这段代码,为啥那个afafafa没有打印出来? public class Demoe { public void f() { System.out.println("Throwing MyException from f()"); } public static void main(String[] args) { Demoe aa = null; try { aa.f(); throw new NullPointerException("afafafa&q

语言-新手求帮忙看下这段代码的数据溢出问题,没有C币理解下(我是在CodeBlock10.05下运行的)

问题描述 新手求帮忙看下这段代码的数据溢出问题,没有C币理解下(我是在CodeBlock10.05下运行的) #include #include #include unsigned int Ex_secret[30]={11,4,120,75,170,204,90,59,78,49,//用0~255的数表示8位2进制,一共240位 148,248,190,137,0,9,17,91,174,105,45,124,177,205,57,97,194,155,120,36}; unsigned in

高分悬赏 请大神指导-超级长得SQL语句,看晕你的头,求大神帮忙看一下这段SQL错在哪里。

问题描述 超级长得SQL语句,看晕你的头,求大神帮忙看一下这段SQL错在哪里. DECLARE @SQL VARCHAR(8000) SET @SQL ='SELECT A.POINT, A.WZ, A.LC, A.PL1, A.PL2, A.XS1, CASE WHEN ISNULL(A.ZDZS,'''') <> '''' THEN A.ZDZS ELSE 0 END AS ZDZS, CASE WHEN ISNULL(A.PJZ,'''') <> '''' THEN A.PJ

在指定的时间段清除定时器,大家帮忙看一下这段代码有什么问题?

问题描述 在指定的时间段清除定时器,大家帮忙看一下这段代码有什么问题? <script type='text/javascript'> var date_time = new Date(); var current_time = date_time.getHours() + ":" + date_time.getMinutes() + ":" + date_time.getSeconds(); if (current_time >= '7:20:0

帮忙看一下这段代码,WINCE下开发

问题描述 写了如下一小段程序,在wince下开发,用模拟器,运行的时候,提示SQLiteerror:nosuchtabletb_isbncj....望各位高手帮忙看一下usingSystem;usingSystem.Linq;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Form

ashx出现错误,帮忙看下这段代码并发的时候有没有问题

问题描述 try{answer=int.Parse(context.Request.Params["answer"].ToString());}catch{answer=0;}try{if(HttpContext.Current.Request.ServerVariables["HTTP_VIA"]!=null){ip=HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR&quo

大家帮忙看下这段代码有什么问题?????

问题描述 usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.OleDb;namespaceFlimManager{publicpartialclassForm1:Form{publicintpower;public

请大家帮忙看一下,这段JS出了什么问题,琢磨好几天了,我就是看着没毛病,但就是实现不了功能!!!!急求JS高手解决一下吧!!!!!!!!

问题描述 我想要实现的功能是这样的:当select标签中的选项一改变,TextBox中被选择的文字就改变了,就加上了别的字符串,请看:看<HTML>代码是这样的:<selectname="zt"id="zt"onchange="javascript:zt()"><option>字体</option><option">黑体</option><option>

高手帮忙看下,这段代码有什么问题...谢谢

问题描述 以下是一个实现GridView表格嵌套的代码......我用AccessDataSource连接Access数据库时运行正常,换成SqlDataSource后运行报错,错误提示也莫名其妙:"第一行:'?'附近有错误"---TEST2.ASPX代码<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="TEST2.aspx.cs"Inherits="TES