PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am trying to code a small shopping cart that when you click checkout it passes everything to paypal. Questions -
A: How should I save the shopping cart infomation for each person? Is doing it through cookies bad? I can't have the user register with me so using a db with stored username and password wont go. Any sugestions on that will be very helpful.
B: Is there any way that anyone knows about that when the person pays their cookies will be deleted as to empty their shopping cart on my server?
Thanks. (and yes I have researched this stuff but have found no answers )
I have worked with Paypal and Authorize.Net and that problem occured with me too. See they have a pre-defined var names that you pass it for the transaction to occur. If you pass it any other var e.g. user_registration_no along with its value it will return that same key-value pair in its response So damn simple
$_SESSIONї'products'] = $_SESSIONї'products'].'*'.$item_name.'*';
$_SESSIONї'total'] = $_SESSIONї'total']+$amount;
$pro = explode('*', $_SESSIONї'products']);
$count = count($pro);
$query = mysql_query("SELECT * FROM items ORDER BY itemid DESC");
while($item = mysql_fetch_assoc($query)){
for($i=0; $i<$count; $i++){
if ($proї$i] == $itemї'name']){
$itm = $itemї'name'];
$_SESSIONї$itm] = $_SESSIONї"$itm"]+1;
}
}
}
while($item = mysql_fetch_assoc($query)){
$itm = $itemї'name'];
foreach($_SESSIONї$itm] as $itmc => $amt){
echo '<br>______________<br>';
echo 'You have '.$amt.' of '.$itmc.'<br>';
echo '<br>______________<br>';
}
}
echo 'Your total is'.$_SESSIONї'total'];
where i think im having the trouble is in setting the session item name with its value. its suposed to for each item you added to your cart it checkes the amount that you want for that item but doing a $_SESSION[$itm]; to make the session thing based on the item name is definatly not working i dont think. any sugestions?...or is this just complete garbage and my only real option is suicide?
but! i have a db that stores the cartID as your session id and there will be multiple rows with your cartID and each has its own itemID. I need to take all of the itemID's and turn them into a array so it will look like
array(123, 542, 67) each number being a seperate itemID where your cartID equals your session id. I dont know the sql to do this. Help?
$result = mysql_query("SELECT itemID FROM cartDB WHERE cartID = '".session_id()."'") or die("Damn! You can't even write SQL correctly!<br>".MySQL_Error()); //;)
while(itemsї] = mysql_fetch_row($result));