从PHP 5.3迁移到5.7但是我的代码被破坏

时间:2017-05-17 19:28:57

标签: php mysql iis web login

我从教程中得到了这个代码,但是我的大学服务器有PHP 5.3,在我自己的家用WebServer上运行PHP5.7,我相信这是导致错误的原因,因为我得到了“这个页面不能正常工作“

这是一个非常基本的登录脚本,因为这就是我所需要的。

我正在跑步 IIS 10.0,PHP 5.7和最新的MySql Server / Windows服务器2016 Stan

我试图在我的服务器上使用的代码是

<?php

//get information from index.php
$username = $_POST['username'];
$password = $_POST['password'];

//Prevent Sql injection
$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

//connect to the MySql Server and select a Database
mysql_connect("localhost", "root", "password");
mysql_select_db("S0190282");
//Query the database for the user
$sql = mysql_query("SELECT * FROM login WHERE username = '$username' AND password = '$password'")
    or die ("Failed to query database".mysql_error());

$row = mysql_fetch_array($sql);
if ($row['username'] == $username && $row['password'] == $password)
{
    //if Username and password are both correct /Do this code here\
    header('Location: secure/index.php');
}
else
{
    //Do this code here
    echo('Your Username or Password is incorrect');
}
?>
无论如何,任何人都知道要解决这个问题。我宁愿不回到5.3,因为我总是使用最新版本的服务器软件。

0 个答案:

没有答案