Jump to content


Photo

Variable question


  • Please log in to reply
24 replies to this topic

#21 fat_bob

fat_bob
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 30 July 2006 - 11:54 AM

But in my other page the
<?php
session_start();
$_SESSION['test'] = "I'm a SESSION";

part.
and the

echo $_SESSION['test'];
?>

aint in the same page.

#22 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 30 July 2006 - 12:04 PM

You have the session_start() at the top of each page where you are using session vaiables?
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#23 fat_bob

fat_bob
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 30 July 2006 - 12:05 PM

Yes

#24 fat_bob

fat_bob
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 30 July 2006 - 12:09 PM

Ok I have now found the "problem" but havent solved it. The thing is that the variables value isnt stored once you press the link and gets to the new page. It seams as it doesnt store the value on the computers memory. (and its not wrong on my computer, its still the script btw^^)


#25 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 30 July 2006 - 01:21 PM

The session should works perfectly, nevermind.. Let's try cookie now.
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("untitled", $con);$result = mysql_query("SELECT * FROM userlogin");while($row = mysql_fetch_array($result))
  {
$userdb = $row['user'];
$passdb = $row['password'];
}mysql_close($con);
$userfo = $_POST["user1"];
$passfo = $_POST["password1"];
if($userdb == $userfo and $passdb == $passfo){
setcookie("loger", "1", time()+3600);
echo "<a href='test.php'>test</a>";

}else{
setcookie("loger", "0", time()+3600);

}
?>

<?php
$loger = $_COOKIE['loger'];
if ($loger == 1) {
   echo "Succes!";
} else {
   echo "Error!";
}
?>


Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users