佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1255|回复: 5

在localhost可以,放上web hosting就不能了

[复制链接]
发表于 25-7-2014 05:31 PM | 显示全部楼层 |阅读模式
大家好,我在localhost弄个admin page.. 可以检查是否log in 然后 display我要的网页。。
可是当我放上webhosting,就不能了。为什么?

<?php

session_start();

include_once('../includes/connection.php');

if(isset($_SESSION['logged_in'])){
        ?>
       
   <!DOCTYPE html>
   <html>
        <head>
        <meta charset="UTF-8">
        <title>Digispace - Control Panel</title>
        <link rel="stylesheet" href="../css/style.css">
        </head>

        <body>

            <!-- Header Wrapper -->
                <div id="header-wrapper">

                    <div id="logo">
                    <h1><a href="index.php">Digispace Control Panel</a></h1>
                    </div>

                </div>

            <!-- Main Wrapper -->
                <div id="main-wrapper">

                <ul class="top_nav">
                <li><a href="../index.php">View Website</a></li>
                </ul>

                <div id="page_title">
                    <h4>Please choose one of the following:</h4>
                               <br/><br/>

                    <a href="add.php" class="admin_a">Add Projects</a><br/><br/>
                    <a href="edit.php" class="admin_a">Delete Projects</a><br/><br/>
                    <a href="logout.php" class="admin_a">Logout</a><br/><br/>
                       
                </div>

                </div><!-- Main Wrap Close -->

        <!-- Footer Wrapper -->
        <div id="footer-wrapper">
            <div id="footer-text">
                <p>
                Copyright &copy; Digispace. All rights reserved.
                </p>
            </div>
        </div>

        </body>
        </html>



        <?php
}else{
        if(isset($_POST['username'],$_POST['password'])){
                $username = $_POST['username'];
                $password = $_POST['password'];
               
                if(empty($username) or empty($password)){
                        $error = 'All fields are required.';
                }else{
                        $query=$pdo->prepare("SELECT * FROM users WHERE user_name=? AND user_password=?");
                       
                        $query->bindValue(1,$username);
                        $query->bindValue(2,$password);
                       
                        $query->execute();
                       
                        $num = $query->rowCount();
                       
                        if($num==1){
                                //user entered correct details
                                $_SESSION['logged_in']=true;
                               
                                header('Location:index.php');
                                exit();
                        }else{
                                //user entered false details
                                $error='Incorrect details!';
                        }
                }
        }
       
       
        ?>
       
        <!DOCTYPE html>
    <html>
        <head>
        <meta charset="UTF-8">
        <title>Digispace - Control Panel</title>
        <link rel="stylesheet" href="../css/style.css">
        </head>

        <body>

            <!-- Header Wrapper -->
                <div id="header-wrapper">

                    <div id="logo">
                    <h1><a href="index.php">Digispace Control Panel</a></h1>
                    </div>

                </div>

            <!-- Main Wrapper -->
                <div id="main-wrapper">

                <ul class="top_nav">
                <li><a href="../index.php">View Website</a></li>
                </ul>

                <div id="page_title">
                    <h4>Kindly login to access admin page</h4>
                               <br/><br/>

                    <?php if(isset($error)){  ?>
                        <small style="color:#aa0000"><?php echo $error; ?>
                        <br/><br/>
                    <?php  }  ?>

                    <form action="index.php" method="post" autocomplete="off">
                        <input type="text" name="username" placeholder="Username"/>
                        <input type="password" name="password" placeholder="Password"/>
                        <input type="submit" value="Login"/>
                    </form>
                </div>

                </div><!-- Main Wrap Close -->

        <!-- Footer Wrapper -->
            <div id="footer-wrapper">
                <div id="footer-text">
                    <p>
                    Copyright &copy; Digispace. All rights reserved.
                    </p>
                </div>
            </div>

        </body>
        </html>
       
<?php
}
?>

回复

使用道具 举报


ADVERTISEMENT

发表于 25-7-2014 07:39 PM | 显示全部楼层
什么error?sql的connection又修改去hosting的?
回复

使用道具 举报

 楼主| 发表于 26-7-2014 06:54 AM | 显示全部楼层
leon_lcl 发表于 25-7-2014 07:39 PM
什么error?sql的connection又修改去hosting的?

没有error.. 修改了.. 已经connect到database了。。

我上网查了。。应该是php session问题。。

session.save_pathC:\php5.3\sessiondata\

可是我的server里没有这个folder,我create folder 了。。还是一样不能。。
回复

使用道具 举报

发表于 26-7-2014 02:38 PM | 显示全部楼层
出现了什么 error message?
回复

使用道具 举报

发表于 26-7-2014 11:18 PM | 显示全部楼层
望聞問切

先不要斷定是不是session的問題, 你先說一下, 你用那間web hosting, 他有沒有提供PHP
丟個 <?php phpinfo(); ?>去web hosting看一下server的設定是身麼.

我覺得web hosting 都是用 linux的, 所以 C:\php5.3\sessiondata\ 是不存在的
因為linux的路徑概念是以 / (root) 為中心

麻煩你參考這個:
參考資料
回复

使用道具 举报

 楼主| 发表于 27-7-2014 11:12 AM | 显示全部楼层
问题解决了。。我email webhosting的admin。。他们说是permission的问题。。现在ok了。。
回复

使用道具 举报

Follow Us
您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 27-8-2025 05:46 PM , Processed in 0.145561 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表