duanjiwang2927 2015-09-21 17:57
浏览 28
已采纳

无法访问fetch dBase数据。 登录页面保持循环回到同一页面

Each time i tried to log in through : webhost/adminlogin.php , am redirected back to thesame page. Is there any thing i forgot to add? Thank you for your help.. Here is my script below

This is my adminlogin.php

<?php session_start(); if(isset($_SESSION[ 'admin_login'])) header( 'location:admin_homepage.php'); ?>

<!DOCTYPE html>
<html>

<head>
  <noscript>
    <meta http-equiv="refresh" content="0;url=no-js.php">
  </noscript>
  <meta charset="UTF-8">
  <title>Admin Login - Online Banking</title>

  <link rel="stylesheet" href="newcss.css">
</head>
<?php include 'header.php'; ?>

<div class='content'>
  <div class="user_login">
    <form action='' method='POST'>
      <table align="center">
        <tr>
          <td><span class="caption">Admin Login</span>
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <hr>
          </td>
        </tr>
        <tr>
          <td>Username:</td>
        </tr>
        <tr>
          <td>
            <input type="text" name="uname" required>
          </td>
        </tr>
        <tr>
          <td>Password:</td>
        </tr>
        <tr>
          <td>
            <input type="password" name="pwd" required>
          </td>
        </tr>
        <tr>
          <td class="button1">
            <input type="submit" name="submitBtn" value="Log In" class="button">
          </td>
        </tr>
      </table>
    </form>
  </div>
</div>

<?php include 'footer.php'; ?>
<?php include '_inc/dbconn.php'; if(!isset($_SESSION[ 'admin_login'])){ if(isset($_REQUEST[ 'submitBtn'])){ $sql="SELECT * FROM admin WHERE id='1'" ; $result=mysql_query($sql); $rws=m ysql_fetch_array($result); $username=m ysql_real_escape_string($_REQUEST[
'uname']); $password=m ysql_real_escape_string($_REQUEST[ 'pwd']); if($username==$rws[8] && $password==$rws[9]) { $_SESSION[ 'admin_login']=1; header( 'location:admin_hompage.php'); } else header( 'location:adminlogin.php'); } } else { header(
'location:admin_hompage.php'); } ?>

</div>
  • 写回答

1条回答 默认 最新

  • dou44364983 2015-09-21 18:45
    关注

    I think there may be a few issues with your script. One obvious one is that you are outputting html content before you send the headers at the bottom of the script.

    HTTP headers must be sent to the client before any other content.

    Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.

    I would suggest that unless you need to continue processing. You move all your login code to the top of the script and call 'exit()'; after you have sent the headers to the client to prevent any further processing or content being sent to the client.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度