Welcome Guest ( Log In | Join )

Discover the best free computer help!
Learn more about Geeks to Go by taking the tour. Want to ask a question, reply to a topic, or remove all advertising? It's easy, fast and free. Join today!
Spyware, virus, trojan, fake security or privacy alerts? Please start with our malware cleaning guide.
     
 
Reply to this topicStart new topic
cookie not working....
TrEzNoR
post Oct 29 2008, 01:36 AM
Post #1


Member
**
Posts: 39
OS: Windows XP



my cookies isn't resetting its self.....can someone point out what is wrong so that it will refresh when it expires. confused1.gif

This is the homepage.php file
CODE
<?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
CODE
<?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.
CODE
<?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. thumbsup.gif
So if someone can help me it would be very helpful for me. Thanks if you do.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 


RSS Time is now: 8th January 2009 - 12:28 AM
Advertisements do not imply our endorsement of that product or service. The forum is run by volunteers who donate their time and expertise. We make every attempt to ensure that the help and advice posted is accurate and will not cause harm to your computer. However, we do not guarantee that they are accurate and they are to be used at your own risk.