Hello and mery christmas and happy new years.
on my site i would like to create a simple php/mysql shopping cart use html form to insert product in shopping cart table.
with the help on forum i created a md5 hash it generate beatyfull code... every time when i click on add to shopping cart on same browse same user it is different hash code. i want to generate same md5 hash code for same user for 30 days, how can i use cookie to to generate same md5 hash code for same user ????
below is my php code where i generate md5 hash code:
<?php
$hash = md5(mt_rand(1, 1000000));
$result = mysql_query("SELECT id FROM shoppingcarttable WHERE client='$hash' LIMIT 1");
if(mysql_num_rows($result) == 1) {
$hash = md5(mt_rand(1, 1000000));
}
if(!isset($_SESSION['MM_username']) && isset($_COOKIE['MM_username'])) {
$_SESSION['MM_username'] = $_COOKIE['MM_username'];
}
?>