my script goes here: <?php session_start(); include "user_session.php"; include "../database.php"; $sid = session_id(); //to deduct the total price from the balance $balance = $balance - $total; $query = mysql_query("update user set amount = '$balance' where user_id='$user_id'"); //put the order placed by the user to ordering to get the order ID $to_ordering = mysql_query("INSERT INTO ordering VALUES (NULL, '$user_id', '$total', '$date_time', now())"); $order_id = mysql_insert_id(); $cart = mysql_query("SELECT * from temp_cart WHERE cart_sess_id='$sid'"); //put the data into orderlist table one row at a time from temp_cart table $row = mysql_num_rows($cart); for($i=0; $i<$row; $i++){ while ($row2 = mysql_fetch_array($cart)) { extract ($row2); $to_orderlist = mysql_query("INSERT INTO orderlist (order_id, food_id, quantity, status) VALUES ('$order_id','$food_id','$qty', 'Not Ready')"); } } //delete from temp_cart table $delete=mysql_query("DELETE FROM temp_cart WHERE cart_sess_id='$sid'"); ?> [/quote] actually this script is posted at the beginning of the script called paid.php. which means that it has html codes at the bottom of the script to display the interface of the web. So from this script, i see that every time this browser is refreshed, the query ----- $to_ordering = mysql_query("INSERT INTO ordering (order_id, user_id, total_price, collection_date, purchase_date) VALUES (NULL, '$user_id', '$total', '$date_time', now())");----- will execute. which means the order_id which i have set as a primary will increase by one. is there any solution to stop the user from pressing refresh or should i write this query somewhere else? after executing this query to the table called ordering, i then will move all the items in temp_cart table to orderlist table. it will get the order_id from the query "ordering table" above. and delete the item in temp_cart after storing them. so when i press refresh in the browser F5, the sentence in the screen showing "your order is 3". when i press again, it shows "your order is 4". but the item purchased was empty. meaning that there is no total item or total price being shown out in the screen. only the order number will keep on increasing. so the ordering table will keep on inserting a new order_id and the same amount of the total, collection_date and purchase_date. is there any solution?