Jump to content

Customer Orders


morrisjohnny
 Share

Recommended Posts

A Local business Sweet Memories has asked for a website. and this is what i have come up with.Link: SweetMemoriesOnline.co.ukNow they wanted a system where people could purchase from their website without having to register so i come up with this idea.To Create the customerID i use a cookie

<?php$expire=time()+3600;$cookiecheck=mysql_query("SELECT * FROM $tbl_cookies WHERE LU<'time()'");while($scookie=mysql_fetch_array($cookiecheck)){mysql_query("DELETE FROM $tbl_cookies WHERE ref='{$scookie['ref']}'");echo mysql_error();}if(!isset($_COOKIE['smshoppingcart'])){	$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("smshoppingcart",$value,time()+3600);		mysql_query("INSERT INTO $tbl_cookies (ref,LU)VALUES('$value','$expire')");	}	else	{		include"auto_cookie.php";	}}else{	setcookie("smshoppingcart",$_COOKIE['smshoppingcart'],time()+3600);	$query="UPDATE $tbl_cookies SET LU='$expire' WHERE ref='".$_COOKIE['smshoppingcart']."'";	if(!mysql_query($query))	{		echo 'ERROR: CID:'.$_COOKIE['smshoppingcart']."; Error:".mysql_error().', <br /><h2>Please Report This Error.</h2>';	}}?>

then i stored their order like this

if(isset($_POST['sweetid'])){	$sweetid=mysql_real_escape_string($_POST['sweetid']);	$quanity=mysql_real_escape_string($_POST['sweetamount']);	$guscheck=mysql_query("SELECT * FROM $tbl_orders WHERE ip='$ip' AND sweetid='$sweetid'");	$suscheck=mysql_fetch_array($guscheck);	if($quanity<0)		{$stockcheck=$suscheck["quantity"]+$quanity;}	else		{$stockcheck=$suscheck["quantity"]+$quanity;}	if($stockcheck<0)	{$basketreport="Sorry, you cannot take out more than you have in your basket.";}	else if($stockcheck==0)	{		$query=mysql_query("DELETE FROM $tbl_orders WHERE sweetid='$sweetid' AND ip='$ip'");	}	else if (mysql_num_rows($guscheck)>0)	{				$query=mysql_query("UPDATE $tbl_orders SET quantity='$stockcheck' WHERE sweetid='$sweetid' AND ip='$ip'");	}	else	{		$query=mysql_query("INSERT INTO $tbl_orders (ip, sweetid, quantity) VALUES ('$ip','$sweetid','$quanity')");	}	if(!$query)	{$basketreport="Sorry, Their was a problem adding your product";} else {$basketreport="Your Request has been Succesful";}}

Now i was wondering is their any flaws this idea or any security corns i should be aware of or have missed?Any feedback on the website would also be appriated. (please note i am converting the weight table into an AJAX postage table which changes depending upon your selection of amount (Quantity)Thanks-Johnny

Link to comment
Share on other sites

Hi, a problem with the cookies is that someone might modify its content, but i guess it would do well.for the design i would have a "frame" or background keeping all together, as it is when i check, it looked like something floating over chocolate(maybe i'm just hungry)

Link to comment
Share on other sites

Hi, a problem with the cookies is that someone might modify its content, but i guess it would do well.
Hi, Firstly thanks for your idea, i considered this upon design and if they changed their cookie they would only be changing their cookie ID so if they created a new cookie id their basket would be empty or if they managed to guess another users cookie they would see their basket. now Worst case senorio would be they used this and kepted updating someone else's basket, However when the customer comes to pay they would notice their basket being full of extra products. and either close the window or update their basket.If they did carry on with their payment it would take them to paypal and seing an overview of the basket on paypal will ensure they are not buying products they wish.
for the design i would have a "frame" or background keeping all together, as it is when i check, it looked like something floating over chocolate(maybe i'm just hungry)
Once again, Thanks for your suggestion :) however i'm affraid i don't understand what you mean? i know there where a few layout faults between Firefox & Internet explorer but i'm sure they where fixxed, can i ask what internet broswer are you using or could you explain a bit better?Thanks once again :)-Johnny
Link to comment
Share on other sites

Hi, i'm using firefox 3.0.12, i trying to say that there was the yellow boxes of menu, content, etc. but they are like islands over the brown background, a border or something to show them as a whole.

Link to comment
Share on other sites

Hi, i'm using firefox 3.0.12, i trying to say that there was the yellow boxes of menu, content, etc. but they are like islands over the brown background, a border or something to show them as a whole.
ah right thanks :) Just to group them together? any kind of colour or style i could do a plain brown/yellow border or background but i though that would look naff. Any suggestions? :)Thanks once again.-Johnny
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...