Jump to content

samantha_chan1

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

samantha_chan1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--coloro:#CC66CC--][span style=\"color:#CC66CC\"][!--/coloro--][b]thanks a lot Yesideez.... you helped me a lot.[!--colorc--][/span][!--/colorc--][/b]
  2. [!--quoteo(post=363221:date=Apr 10 2006, 04:44 PM:name=Yesideez)--][div class=\'quotetop\']QUOTE(Yesideez @ Apr 10 2006, 04:44 PM) [snapback]363221[/snapback][/div][div class=\'quotemain\'][!--quotec--] Set up a form in the firest page and make a hidden input: [code]<input type="hidden" name="cheeseopt" value="notliked">[/code] Then on the second script use something like this: [code]$cheese=$_POST['cheeseopt'];[/code] Use $_POST if in your form you use method="post" and $_GET if you use method="get" The difference is POST sends the form data in a packet whereas GET adds the form data onto the end of the URL and sends it that way - POST is more secure. [/quote] But i am posting the variable in a script to another page. the script is not in the html. so i can't but a hidden field in it. does there have any other solution?
  3. how can i post a variable let's say $total from 1st page to xx.php while i am using a header("locaiton : xx.php") in 1st page?
  4. How could i prevent a user from hitting the refresh button in the browser? If the user hit the refresh button, the data will then be posted to database as a new record with a new primary key which i have set it as an auto increment primary key. How can i avoid this from happening? what is the difference between using (1)include "hello.php" and (2) header (Location:"hello.php");?
  5. 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?
  6. [b]I am currently generating a receipt when the order ID as a primary key when an auto increment function. But when i refresh the page, the order ID will automatically increase by itself. How should i avoid this incident from happening? I do not what an auto increment in order_id when users press Refresh (F5). [/b] 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'"); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.