我的问题是我的会话在localhost上正常工作,但是当我在服务器上传它时总会产生问题。有趣的是,我上传的每台服务器都有问题。我的localhost有什么问题吗。
问题:我这次遇到的问题是会话是在本地页面上设置的,这意味着当我通过登录设置会话时,它会在登录页面上设置但在其他页面上保持未设置
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Belvic Print - Register</title>
<meta name="description" content="Printing template">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=yes"/>
<meta name="author" content="Netbase">
<!--Add css lib-->
<link rel="stylesheet" type="text/css" href="css/style-main.css">
<link href='http://fonts.googleapis.com/css?family=Roboto:500,300,700,400' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'>
</head>
<body>
<!--Header: Begin-->
<header>
<!--Top Header: Begin-->a-home"></i>
<span>Thessaly House, Thessaly Road, London, SW8 4EB</span>
</li>
<li>
<i class="fa fa-phone"></i>
<span>0203 868 3785</span>
</li>
<li>
<i class="fa fa-envelope-o"></i>
<span><a href="mailto:support@netbaseteam.net" title="send mail to Cmsmart">support@netbaseteam.net</a></sp</li>
<li>
<a href="#" title="FAQ">FAQ</a>
</li>
<li>
<a href="#" title="Design Service">Design Services</a>
</li>
<li>
<a href="#" title="Contact Us">Contact Us</a>
</li>
</ul>
</div>
</div>
<div class="col-md-3 col-xs-12 other-info footer-col hidden-sm">
<h2>Other Info</h2>
<div class="footer-content">
<p>
Printmart provides fast online printing for both homes and businesses. We provide high quality business cards, postcards, flyers, brochures, stationery and other premium online print products.
</p>
<img src="images/footer-payment.png" alt="Payment method">
</div>
</div>
</div>
</div>
</div>
<div class="footer-bottom">
<div class="container">
<div class="row">
<div class="col-md-12">
<p class="copy-right">Central - Copyright © 2015 <a title="Cmsmart - Magento theme" href="#">netbaseteam.com</a>. All Rights Reserved</p>
<a href="#" id="back-to-top">
<i class="fa fa-chevron-up"></i>
Top
</a>
</div>
</div>
</div>
</div>
</footer>
<div id="sitebodyoverlay"></div>
<nav id="mb-main-menu" class="main-menu">
<div class="mb-menu-title">
<h3>Navigation</h3>
<span id="close-mb-menu">
<i class="fa fa-times-circle"></i>
</span>
</div>
<ul class="cate_list">
<li class="level0 parent col1 all-product">
<a href="#">
<span>All Product</span>
<i class="fa fa-chevron-down"></i><i class="fa fa-chevron-right"></i>
</a>
<ul class="level0">
<li class="level1">
<a href="#" title="Business Card">Business Card</a>
</li>
<li class="level1">
<a href="#" title="Premium Business Card">Premium Business Card</a>
</li>
<li class="level1">
<a href="#" title="Free Business Card">Free Business Card</a>
</li>
<li class="level1">
<a href="#" title="Marketing Materials">Marketing Materials</a>
</li>
<li class="level1">
<a href="#" title="Dance Marketing Kit">Dance Marketing Kit</a>
</li>
<li class="level1 view-all-pro">
<a href="#" title="view all product">View all</a>
</li>
</ul>
</li>
<li class="level0 parent col1">
<a href="#" title="Business Cards">
<span>Business Cards</span>
<i class="fa fa-chevron-down"></i><i class="fa fa-chevron-right"></i>
</a>
<ul class="level0">
<li class="level1 nav-1-1 first item">
<a href="#" title="Premium Business Cards">Premium Business Cards</a>
</li>
<li class="level1 nav-1-2 item">
<a href="#" title="Free Business Cards">Free Business Cards</a>
</li>
<li class="level1 nav-1-3 item">
<a href="#" title="Die-Cut Business Cards">Die-Cut Business Cards</a>
</li>
<li class="level1 nav-1-4 item">
<a href="#" title="Standard Business Cards">Standard Business Cards</a>
</li>
<li class="level1 nav-1-5 item">
<a href="#" class="Personal Business Cards">Personal Business Cards</a>
</li>
<li class="level1 nav-1-6 item">
<a href="#" title="Business Card Holders">Business Card Holders</a>
</li>
<li class="level1 nav-1-7 item">
<a href="#" title="Networking Cards">Networking Cards</a>
</li>
<li class="level1 nav-1-8 item">
<a href="#" title="Appointment Cards">Appointment Cards</a>
</li>
<li class="level1 nav-1-9 last item">
<a href="#" title="Mommy Cards">Mommy Cards</a>
</li>
</ul>
</li>
<li class="level0">
<a href="#" title="Marketing">Marketing</a>
</li>
<li class="level0">
<a href="#" title="Postcards">Postcards</a>
</li>
<li class="level0">
<a href="#" title="Stickers & Badges">Stickers & Badges</a>
</li>
<li class="level0" title="Promotional">
<a href="#">Promotional</a>
</li>
</ul>
</nav>
<!--Add js lib-->
<script type="text/javascript" src="js/jquery/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/jquery/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/modernizr.js"></script>
<script type="text/javascript" src="js/jquery.animateSlider.min.js"></script>
<script type="text/javascript" src="js/owl.carousel.min.js"></script>
<script type="text/javascript" src="js/theme.js"></script>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</body>
</html>
<?php
include("db.php");
if(isset($_POST['register'])) {
// , , , ,
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$password = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
$_username = $_POST['username'];
$status = "new";
$rank="user";
if($password==$confirmpassword)
{
$checkforregister = "SELECT * FROM user WHERE email='$email'";
if($result=mysqli_query($conn,$checkforregister)) {
if (mysqli_num_rows($result) != 1) {
$insert = "INSERT INTO user (first_name, last_name, email, password, username,status,rank) VALUES
('$fname','$lname','$email','$password','$_username','$status','$rank')";
if(mysqli_query($conn,$insert)) {
$last_id = mysqli_insert_id($conn);
$_SESSION['id'] = $last_id;
$userRecord = mysqli_query($conn, "SELECT * FROM user WHERE id='$last_id'");
while ($recordLoop = mysqli_fetch_array($userRecord)) {
$_SESSION['rank'] = $recordLoop['rank'];
}
?>
<script>
window.location="index.php";
</script>
<?php
}
else
{
echo mysqli_error($conn);
}
}
else
{
echo "<div class='span6' style='margin-top: -7%'><p style='color: red;bottom: 50%'>Your email already exists</p></div>";
}
}
}
else
{
echo "<div class='span6' style='margin-top: -7%'><p style='color: red;bottom: 50%'>Your password doesn't match</p></div>";
}
}
if(isset($_POST['login']))
{
$emailLogin = $_POST['emailLogin'];
$passwordLogin = $_POST['passwordLogin'];
$login_query="SELECT * FROM user WHERE email='$emailLogin' AND password='$passwordLogin'";
$run=mysqli_query($conn,$login_query) or die($conn);
if(mysqli_num_rows($run)>0) {
$res = mysqli_query($conn, "SELECT * FROM user WHERE email='$emailLogin'");
while ($record = mysqli_fetch_array($res)) {
$_SESSION['id'] = $record['id'];
$_SESSION['rank'] = $record['rank'];
}
echo $_SESSION['id'];
?>
<script>
window.location="index.php";
</script>
<?php
}
else
{
echo "<div class='span6' style='margin-top: -7%'><p style='color: red;bottom: 50%'>Your email or pssword is incorrect</p></div>";
}
}
?>