cookie not working.... |
![]() ![]() |
cookie not working.... |
Oct 29 2008, 01:36 AM
Post
#1
|
|
|
Member ![]() ![]() Posts: 39 OS: Windows XP |
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. So if someone can help me it would be very helpful for me. Thanks if you do. |
|
|
![]() ![]() |
Similar Topics
| Topic Title | Replies / Views | Topic Information | |||||
|---|---|---|---|---|---|---|---|
![]() |
4 / 326 | 16th November 2008 - 08:39 PM robbyandtina started - last by emeraldnzl |
|||||
![]() |
0 / 24 | 4th January 2009 - 11:54 PM Hawkmoon started - last by Hawkmoon |
|||||
![]() |
1 / 42 | 5th January 2009 - 10:58 PM kae_bayb started - last by jrm20 |
|||||
![]() |
0 / 17 | 6th January 2009 - 04:17 PM cutehumor started - last by cutehumor |
|||||
|
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. |