2015-11-02 138 views
0

我在uni制作了一个网站http://www.mandyevansartist.com,并且它已经在ipage上工作 - 因为移动到1and1它不起作用。当它到达时间,但信息丢失下一页会话php5.5 mysqli没有存储信息

<?php 
session_start(); 
include 'header.php'; 
$id = isset($_GET['id']) ? $_GET['id'] : ""; 
$con = mysqli_connect("*","*","*","*"); 
$db = mysqli_select_db("images", $con); 

function GetCartId() 
{ 

    if(isset($_COOKIE["cartId"])) 
    { 
     return $_COOKIE["cartId"]; 
    } 
    else 
    { 
     setcookie("cartId", session_id(), time() + ((3600 * 24) * 30)); 
     return session_id(); 
    } 
} 
$id = $_GET["id"]; 
$strSQL = "SELECT * FROM images WHERE image= '$id'"; 
$rs = mysqli_query($con,$strSQL); 

while($row = mysqli_fetch_array($rs)) { 

    $name = $row['image_name']; 
    echo '<h1 style="font-size:2em;">'; 
    echo $name; 
    echo'</h1>'; 
    echo '<div id = "galpic">'; 
    $thispic = $row['image']; 
    echo '<div id = "pic">';   
    echo '<br /> <img src="'.$thispic.'" style = "max-width:100%;"/> '; 
    echo '</div>';  
    $description = $row['image_description']; 
    echo ' <a href="#" class="big-link" data-reveal-id="about" data-animation="fade"><h3>about</h3></a>'; 
    echo ' <a href="#" class="big-link" data-reveal-id="card" data-animation="fade"><h3>card</h3></a>'; 
    echo '</div>';  
} 
$_SESSION['name']=$name; 
$_SESSION['thispic']=$thispic; 
echo '<div id="about" class="reveal-modal">'; 
echo '<br /> <img src="'.$thispic.'" /> '; 
echo '<h1>'; 
echo $description; 
echo '</h1>'; 
echo '</div>'; 
echo '<div id="card" class="reveal-modal">'; 
echo '<br /> <img src="'.$thispic.'" /> '; 
echo '<img src="images/cards.png" /> '; 
echo '<h1>a card of -'.$name.'</h1>'; 
echo '<p>click this button and we will hand make you this card. Using spray glue on recycled card and a crystal archive photograph. Individually wrapped with a c5 envelope. </p>'; 
echo '<h1>$7 each</h1><br />'; 

echo '<form action = "cart.php" method = "post">'; 
echo '<input type="image" src = "images/sendtocart.png" >'; 
echo '</form>'; 
echo '<p> you can remove it from the cart later if you like</p>'; 
echo '</div>'; 

$catagory = mysqli_query($con,"SELECT catagory FROM images WHERE image= '$id'"); 
echo '<p>'; 
while ($row = mysqli_fetch_array($catagory)) { 
    $yay= $row[catagory]; 
} 
$answer = mysqli_query($con,"SELECT image FROM images where catagory = '$yay'"); 
echo '<div id = "list">'; 
echo '<hr></hr>'; 
echo '<p>other pictures in this catagory</p>'; 
echo '<ul>';   
while ($row = mysqli_fetch_array($answer)) { 
    $pic = $row['image'];  
    $link ="<a href = 'image.php?id=".$row['image']."'>". ' <img src="'.$pic.'" style ="height:45px;"/> '. "</a>"; 
    echo '<li>' .$link.'</li>';  
} 
echo '</ul>'; 
echo '</div>'; 

$answer = mysqli_query($con,"SELECT image FROM images where HEAD = 'true'"); 
echo '<div id = "list">'; 
echo '<hr></hr>'; 
echo '<p>choose another catagory</p>'; 
echo '<ul>';   
while ($row=mysqli_fetch_array($answer)) { 
    $pic = $row[image];  
    $link ="<a href = 'catagory.php?id=".$row[image]."'>".' <img  src="'.$pic.'" style ="height:60px;"/>'."</a>"; 
    echo '<li>'.$link.'</li>';  
} 
echo '</ul>'; 
echo '</div>'; 
include 'footer.php'; 
?> 
<a class="close-reveal-modal"></a> 

上 - 会话信息工程的第一页(半年下来

$_SESSION['name']=$name; 
$_SESSION['thispic']=$thispic; 

方式创建并弹出模态工作接下来的页面中的会话信息不见了

 <?php 
session_start(); 
$_SESSION['name']=$name; 
$_SESSION['thispic']=$thispic; 
$con = mysqli_connect("*","*","*","*"); 
function GetCartId() 
{ 
    if(isset($_COOKIE["cartId"])) 
    { 
     return $_COOKIE["cartId"]; 
    } 
    else 
    { 
     setcookie("cartId", session_id(), time() + ((3600 * 24) * 30)); 
     return session_id(); 
    } 
} 
mysqli_query($con,"insert into cart(product,name,image,price,cookieId) values('card','$name','$thispic',7,'".GetCartId()."')"); 
header("Location:image.php?id=$thispic"); 
?> 
+0

问题就迎刃而解了 - 这是主人的1and1没有“超全局变量”打开 - 所以我加了这个代码,以我的培训相关的网页(刚下在session_start顶部( )..... //在 上模拟register_globals if(!ini_get('register_globals')){ $ superglobals = array($ _ SERVER,$ _ENV, $ _FILES,$ _COOKIE,$ _POST,$ _GET);如果(isset($ _ SESSION)){ array_unshift($ superglobals,$ _SESSION); } foreach($ superglobals as $ superglobal){ extract($ superglobal,EXTR_SKIP); } } –

回答

0

问题就迎刃而解了 - 这是主人的1and1没有“超全局变量”打开 - 所以我加了这个代码,以我的培训相关的网页(强制顶部下在session_start()笔.....

// Emulate register_globals on 
if (!ini_get('register_globals')) { 
    $superglobals = array($_SERVER, $_ENV, 
    $_FILES, $_COOKIE, $_POST, $_GET); 
if (isset($_SESSION)) { 
    array_unshift($superglobals, $_SESSION); 
} 
foreach ($superglobals as $superglobal) { 
    extract($superglobal, EXTR_SKIP); 
} 
    }