Php 登录脚本在较新的服务器上不起作用

涡流

我将登录 php 脚本从相当旧的服务器移到了较新的服务器。所有设置和 chmods 都相同,但 php 脚本在较新的服务器上不起作用。当输入正确的登录名和密码时,它不会转到 main.php 而是停留在 index.php 登录页面上并添加此消息“无效的用户名或密码!'; } } ?>”。

我是一个编程菜鸟,但也许脚本使用了某些在较新的服务器上最好不要再使用的编码。任何想法更改脚本以便它可以再次工作?先感谢您。

下面是 index.php 登录页面的代码:

<?
ob_start("ob_gzhandler");
session_start();

$username = "admin";
$password = "admin";

// main page
$mainpage = "main.php";

if(isset($_SESSION['logedin']))
if($_SESSION['logedin'] == 'loggedin')
{
header("Location: $mainpage");
exit(); 
}

if(isset($_POST['submit']))
{

if($_POST['username'] == $username && $_POST['password'] == $password)
{
        $_SESSION['logedin'] = 'loggedin';

        // Redirect to the page
        header("Location: $mainpage");
        exit();
}
else
{
        $error = '<br /><br />Invalid Username or Password!';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-US">
<head>
<title>test</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<style type="text/css">
html, body, #wrapper {
    height:100%;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
}
#wrapper td {
    vertical-align: middle;
    text-align: center;
}
#headerBox {
    border: 1px solid #A6E0FF;
    width: 800px;
    color: #00529B;
    background: #EDF8FE;
    height: 150px;
    text-align: center;
    margin: 0px auto;
}
#top {
    color: #00529B;
    background: #DAF3FF;
    text-align: center;
    border-bottom: 1px solid #BFE9FF;
    padding-top: 10px;
    padding-bottom: 10px;
    font-weight:bold;

}
#bottom {
    color: #00529B;
    background: #EDF8FE;
    text-align: center;
    padding-top: 30px;
}
</style>
</head>
<body>
<table id="wrapper">
<tr>
<td>
<div id="headerBox">
<form method="post" id="login" action="index.php">
<div id="top">Log In</div>
<div id="bottom">
Username: <input id="username" name="username" type="text" />
Password: <input id="password" name="password" type="password" />
<input type="submit" name="submit" id="submit" value="Log in" />
<? if(isset($error)) echo $error; ?>
</div>
</form>
</div>
</td>
</tr>
</table>
<script type="text/javascript">
//<![CDATA[
<!--
document.getElementById("username").focus();
//-->
//]]>
</script>
</body>
</html>
利安德·艾弗森

你似乎在 if 语句之后缺少一个左括号,所以这应该有效:

<?php

ob_start("ob_gzhandler");
session_start();

$username = "admin";
$password = "admin";

// main page
$mainpage = "main.php";

if(isset($_SESSION['logedin']))
{
  if($_SESSION['logedin'] == 'loggedin')
  {
    header("Location: $mainpage");
    exit(); 
  }
}

if(isset($_POST['submit']))
{

  if($_POST['username'] == $username && $_POST['password'] == $password)
  {
    $_SESSION['logedin'] = 'loggedin';

    // Redirect to the page
    header("Location: $mainpage");
    exit();
  }
  else
  {
    $error = '<br /><br />Invalid Username or Password!';
  }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-US">
<head>
<title>test</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<style type="text/css">
html, body, #wrapper {
    height:100%;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
}
#wrapper td {
    vertical-align: middle;
    text-align: center;
}
#headerBox {
    border: 1px solid #A6E0FF;
    width: 800px;
    color: #00529B;
    background: #EDF8FE;
    height: 150px;
    text-align: center;
    margin: 0px auto;
}
#top {
    color: #00529B;
    background: #DAF3FF;
    text-align: center;
    border-bottom: 1px solid #BFE9FF;
    padding-top: 10px;
    padding-bottom: 10px;
    font-weight:bold;    

}
#bottom {
    color: #00529B;
    background: #EDF8FE;
    text-align: center;
    padding-top: 30px;
}
</style>
</head>
<body>
<table id="wrapper">
<tr>
<td>
<div id="headerBox">
<form method="post" id="login" action="index.php">
<div id="top">Log In</div>
<div id="bottom">
Username: <input id="username" name="username" type="text" />
Password: <input id="password" name="password" type="password" />
<input type="submit" name="submit" id="submit" value="Log in" />
<?php if(isset($error)) { echo $error; } ?>
</div>
</form>
</div>
</td>
</tr>
</table>
<script type="text/javascript">
//<![CDATA[
<!--
document.getElementById("username").focus();
//-->
//]]>
</script>
</body>
</html>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

PHP chmod()在服务器上不起作用

来自分类Dev

PHP PhantomJS在Web服务器上不起作用

来自分类Dev

PHP在Apache服务器上不起作用

来自分类Dev

ZipArchive在服务器php上不起作用

来自分类Dev

PHP包括在Xampp服务器上不起作用

来自分类Dev

PHP 标头在服务器上不起作用?

来自分类Dev

简单的PHP Mail函数在Amazon服务器EC2上不起作用

来自分类Dev

静态方法在PHP的Web服务器上不起作用

来自分类Dev

PHP邮件功能在我的服务器上不起作用?

来自分类Dev

PHP正则表达式在真实服务器上不起作用

来自分类Dev

PHP 7.2 fastcgi在Ubuntu 18.04服务器上不起作用

来自分类Dev

upload.php在我的服务器上不起作用

来自分类Dev

PHP重定向在生产服务器上不起作用

来自分类Dev

PHP多个文件上传在服务器上不起作用

来自分类Dev

PHP Autoloader在Ubuntu生产服务器上不起作用

来自分类Dev

upload.php在我的服务器上不起作用

来自分类Dev

PHP 7.2 fastcgi在Ubuntu 18.04服务器上不起作用

来自分类Dev

PHP mail()在digitalocean ubuntu 16.04服务器上不起作用

来自分类Dev

使用 PHP 的 HTTP 身份验证在服务器上不起作用

来自分类Dev

PHP邮件功能在服务器上不起作用

来自分类Dev

PHP Captcha 在服务器上不起作用,但在本地工作

来自分类Dev

使用WAMP服务器时PHP脚本不起作用

来自分类Dev

php邮件功能在新服务器中不起作用

来自分类Dev

php:$ var!= NULL不起作用的远程服务器

来自分类Dev

php file()方法在服务器中不起作用

来自分类Dev

加密方法在较新的 php 版本中不起作用

来自分类Dev

Guzzle在一台服务器上不起作用,但在另一台PHP FB SDK上

来自分类Dev

新的PHP文件在cPanel上不起作用

来自分类Dev

新的PHP文件在cPanel上不起作用

Related 相关文章

  1. 1

    PHP chmod()在服务器上不起作用

  2. 2

    PHP PhantomJS在Web服务器上不起作用

  3. 3

    PHP在Apache服务器上不起作用

  4. 4

    ZipArchive在服务器php上不起作用

  5. 5

    PHP包括在Xampp服务器上不起作用

  6. 6

    PHP 标头在服务器上不起作用?

  7. 7

    简单的PHP Mail函数在Amazon服务器EC2上不起作用

  8. 8

    静态方法在PHP的Web服务器上不起作用

  9. 9

    PHP邮件功能在我的服务器上不起作用?

  10. 10

    PHP正则表达式在真实服务器上不起作用

  11. 11

    PHP 7.2 fastcgi在Ubuntu 18.04服务器上不起作用

  12. 12

    upload.php在我的服务器上不起作用

  13. 13

    PHP重定向在生产服务器上不起作用

  14. 14

    PHP多个文件上传在服务器上不起作用

  15. 15

    PHP Autoloader在Ubuntu生产服务器上不起作用

  16. 16

    upload.php在我的服务器上不起作用

  17. 17

    PHP 7.2 fastcgi在Ubuntu 18.04服务器上不起作用

  18. 18

    PHP mail()在digitalocean ubuntu 16.04服务器上不起作用

  19. 19

    使用 PHP 的 HTTP 身份验证在服务器上不起作用

  20. 20

    PHP邮件功能在服务器上不起作用

  21. 21

    PHP Captcha 在服务器上不起作用,但在本地工作

  22. 22

    使用WAMP服务器时PHP脚本不起作用

  23. 23

    php邮件功能在新服务器中不起作用

  24. 24

    php:$ var!= NULL不起作用的远程服务器

  25. 25

    php file()方法在服务器中不起作用

  26. 26

    加密方法在较新的 php 版本中不起作用

  27. 27

    Guzzle在一台服务器上不起作用,但在另一台PHP FB SDK上

  28. 28

    新的PHP文件在cPanel上不起作用

  29. 29

    新的PHP文件在cPanel上不起作用

热门标签

归档