Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

cookie not working....


  • Please log in to reply

#1
TrEzNoR

TrEzNoR

    Member

  • Member
  • PipPip
  • 39 posts
my cookies isn't resetting its self.....can someone point out what is wrong so that it will refresh when it expires. :)

This is the homepage.php file
<?php
$page_title = "Home page";
$page = "home";
include("gettheme.php");
include("top.php");
?>
<div id="<?php echo $main; ?>">
<h3 align="center"></h3>

<div id="<?php echo $topnav; ?>">
<?php
include("../navig/home.php");
?>
</div>

<div id="<?php echo "$leftcol"; ?>"><h1 align="center"></h1>
<p align="center"><a href="../pages/updates.php" target="_self" >Last updates</a><br><a href="../comments/comments.html" target="_self" >Comment</a><br> <br>
<?php
include("../rating/home/rating.php");
?>
</div>

<div id="<?php echo "$centercol"; ?>">

</div>

<div id="<?php echo "$botnav"; ?>">
<?php
include("../navig/home.php");
include("../navig/style.php");
include("pagecount.php"); 
echo "You are visitor number:". $count;
?>
</div>

</div>
</div>
</div>
<?php
include("btm.php");
?>


This is the rated.php file where the cookie is set
<?php 
setcookie("home", "home", time()+3600);
?>
<html><head><link rel="stylesheet" type="text/css" href="../donerating.css"></head><body>
<?php
/*				  Name of the page									   */
$page = $_POST['page'];
/*				  The rating 1 to 10									   */
$rating = $_POST['rating'];
/*													  */
include("check.php");
/*													  */
/*			  +1 to the current rating				*/
switch($rating){
  case "1":
	  $one += 1;
	  echo "added one to rating for " . $page;
	mysql_query("UPDATE home SET one='$one' WHERE one='".$row['one']."'") or die(mysql_error());
	  break;
  case "2":
	  $two += 1;
	  echo "added one to rating for " . $page;
	mysql_query("UPDATE home SET two='$two' WHERE two='".$row['two']."'") or die(mysql_error());
	  break;
  case "3":
	  $three += 1;
	  echo "added one to rating for " . $page;
	mysql_query("UPDATE home SET three='$three' WHERE three='".$row['three']."'") or die(mysql_error());
	  break;
  case "4":
	  $four += 1;
	  echo "added one to rating for " . $page;
	mysql_query("UPDATE home SET four='$four' WHERE four='".$row['four']."'") or die(mysql_error());
	  break;
  case "5":
	  $five += 1;
	  echo "added one to rating for " . $page;
	mysql_query("UPDATE home SET five='$five' WHERE five='".$row['five']."'") or die(mysql_error());
	  echo 'completed rating 5';
	  break;
  case "6":
	  $six += 1;
	  echo "added one to rating for " . $page;
	mysql_query("UPDATE home SET six='$six' WHERE six='".$row['six']."'") or die(mysql_error());
	  break;
  case "7":
	  $seven += 1;
	  echo "added one to rating for " . $page;
	mysql_query("UPDATE home SET seven='$seven' WHERE seven='".$row['seven']."'") or die(mysql_error());
	  break;
  case "8":
	  $eight += 1;
	  echo "added one to rating for " . $page;
	mysql_query("UPDATE home SET eight='$eight' WHERE eight='".$row['eight']."'") or die(mysql_error());
	  break;
  case "9":
	  $nine += 1;
	  echo "added one to rating for " . $page;
	mysql_query("UPDATE home SET nine='$nine' WHERE nine='".$row['nine']."'") or die(mysql_error());
	  break;
  case "10":
	  $ten += 1;
	  echo "added one to rating for " . $page;
mysql_query("UPDATE home SET ten='$ten' WHERE ten='".$row['ten']."'") or die(mysql_error());
	  break;
  default:
	  echo "failed to add one";
	  break;
}
/*					 End of +1 to current rating									*/
?>
<div id="donerating">
<p>click 
<a href="http://something.com/<?php echo $page . ".php";?>">here</a>to return to <?php echo $page; ?>, or check out the <a href="http://something.com/totalrating.php">total rating here</a>
</div>
</body></html>

This is the rating.php file where the cookie is checked if set.
<?php
if(isset($_COOKIE['home']))
	  $hrated = 1;
else
	  $hrated = 0;
switch ($hrated){
   case "1":
	  echo '<div id="rate">
<p>Rate this page</p>
<form method="post" action="../rated.php">
<select name="rating">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
<input type="hidden" value="home" name="page">
<input type="submit" value="Finished?">
</form>
</div>';
  break;
	case "0":
	  echo "This page has been rated";
  break;
}
?>

the rating.php is included on the homepage.php in the div id left col
Also if I can optimize the code as well that would be good too. :)
So if someone can help me it would be very helpful for me. Thanks if you do.
  • 0

Advertisements







Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP