morrisjohnny Posted April 6, 2009 Share Posted April 6, 2009 I'm trying to create a shopping cart for www.SweetMemoriesOnline.co.uk as i'm redesigning their website (The Payment will still be managed By Paypal)Here's my attempt of setting a cookie <?phpif(isset($_COOKIE['smshoppingcart'])){ setcookie("smchoppingcart",$_COOKIE['smshoppingcart'],time()+3600); mysql_query("UPDATE $tbl_cookies SET LU=(time()+3600)");}else{ $value=mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9).mt_rand(5, 9); $cookiedb=mysql_query("SELECT * FROM $tbl_cookies WHERE ref='$value'"); if(mysql_num_rows($cookiedb)==0) { setcookie("smchoppingcart",$value,time()+3600); mysql_query("INSERT INTO $tbl_cookies (ref,LU)VALUES('$value','time()+3600')"); } else { include"auto_cookie.php"; }}echo mysql_error();echo $value;echo '<br /><br />z|'.$_COOKIE['smshoppingcart'].'|z<br /><br />';?> This is called by shoppingcart.phpa-track of their basket. I was going to use their IP but if they become disconnect and reconnect chances are a new ip may be in order. <?phpinclude"auto_cookie.php";.... index.php (the only viewable page) <?phpinclude"Settings/__connect__.php";$db=mysql_connect($sql_host, $sql_user, $sql_password);mysql_select_db($sql_database, $db);include"shoppingcart.php"; Anyone interested in comments i've included a quick screenshotScreenshot Link to comment Share on other sites More sharing options...
zppblood Posted April 6, 2009 Share Posted April 6, 2009 setcookie("smchoppingcart",$value,time()+3600);You are setting smchoppingcart in two places in both the if and else. You might want to change smchoppingcart to smshoppingcart. Link to comment Share on other sites More sharing options...
morrisjohnny Posted April 6, 2009 Author Share Posted April 6, 2009 setcookie("smchoppingcart",$value,time()+3600);You are setting smchoppingcart in two places in both the if and else. You might want to change smchoppingcart to smshoppingcart.Cheers, i copied and pasted the values but type it wrong in the first statment lol Newbie mistake, Sorry, Working fine now Cheers Mate Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.