脚本不在服务器上工作,但在localhost上工作正常

时间:2013-10-06 18:32:59

标签: php mysql

我的脚本有问题,我做了一个登录脚本,你输入用户名和密码,它在我的本地主机上完美运行(即我可以登录进出管理面板)我然后上传它我的服务器,但令人困惑的部分是,当我尝试使用正确的用户名和密码登录时,它没有访问管理面板并向我显示访问被拒绝的消息,就像会话没有在服务器上设置,而它完全在我的工作本地主持人..其次我创建了一个新闻页面,在那里我可以查看新闻,它还显示没有帖子显示但在本地主机上一切都完美正常 这是我的home.php,我输入用户名和密码

<?php

if(isset($_COOKIE['testsite'])){

    header('Location: enter.php');

}else{

echo"
<html>

<head>

</head>

<body>

<center>Please login...</center>


<div align='center'>
<form method='post' action='login.php' id='generalform'>
<table border='1' width='25%'>
<tr><td>Name: </td><td><input type='text' name='name' maxlength='15'/></td></tr><br />
<tr><td>Password: </td><td><input type='password' name='password' maxlength='15'/></td></tr><br />
<tr><td>Remember me?: </td><td><input type='checkbox' name='remember'/></td></tr><br />
</table>
<p>
<input type='submit' value='login' /><p>
</form>
<a href='index.htm'>Back To Main Page</a>
</div>

</body>

</html>";
}
?>

这是enter.php,正在访问

<?php

session_start();

if(isset($_SESSION['name'])||isset($_COOKIE['testsite'])){

    include('session.php');

}else{

    echo "Access denied!";

}

?>

这是我的news.php似乎没有从数据库访问这个淘气器我真的不知道什么是错的,因为在locahost它的工作完美

 <?php
include ('connect.php');
$query = "SELECT id, title, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts";
$result = @mysql_query($query);

if ($result) {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$url = 'comments.php?id='.$row['id'];
echo '<p><b>'.$row['title'].'</b><br />
'.$row['sd'].'<br />
Posted by : <b>'.$row['author'].'</b><br />
'.$row['post'].'<br />
<a href="javascript:openComments(\''.$url.'\')">Add new comment or view posted comments</a></p>';
}
} else {
echo 'There are no news posts to display';
}
?> 

这是login.php

<?php
session_start();

if($_POST){

$_SESSION['name'] = $_POST['name'];
$_SESSION['password'] = md5($_POST['password']);


if($_SESSION['name'] && $_SESSION['password']){

    mysql_connect("localhost", "root", "nokiae71") or die("problem with connection...");
    mysql_select_db("testsite");

    $query = mysql_query("SELECT * FROM users WHERE name='".$_SESSION['name']."'");
    $numrows = mysql_num_rows($query);

    if($numrows != 0){

        while($row = mysql_fetch_assoc($query)){

            $dbname = $row['name'];
            $dbpassword = $row['password'];

        }
        if($_SESSION['name']==$dbname){
            if($_SESSION['password']==$dbpassword){

                if(($_POST['remember']) == 'on'){
                    $expire = time()+86400;
                    setcookie('testsite', $_POST['name'], $expire);
                }
                header("location:enter.php");

            }else{
                echo "Your password is incorrect!";
            }

        }else{
            echo "Your name is incorrect!";
        }

    }else{
        echo "This name is not registered!";    
    }

}else{
    echo "You have to type a name and password!";
}
}else{

echo "Access denied!";
exit;
}
?>

提前致谢

0 个答案:

没有答案