查看: 1255|回复: 5
|
在localhost可以,放上web hosting就不能了
[复制链接]
|
|
大家好,我在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 © 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 © Digispace. All rights reserved.
</p>
</div>
</div>
</body>
</html>
<?php
}
?>
|
|
|
|
|
|
|
|
发表于 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_path | C:\php5.3\sessiondata\ |
可是我的server里没有这个folder,我create folder 了。。还是一样不能。。
|
|
|
|
|
|
|
|
发表于 26-7-2014 02:38 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 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了。。 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|