hai....
i developing online food ordering system....so if user click order online, tey wil c da food pictures....so if user click da food picture to buy....tey wil c the food category,price n food name plus the food pic 2....at da same page user aso need to enter thier apartment name, room no, email n quntity....after they keyin this info and click buy the info tat need 2 enter in db is food category,price, food name,apartment name, room no, email n quntity.so there is prob in my script....if i use thiese code there is an error but if i del id,type,price n desc in da coding,it works well ..but i oni cn c apartment name, room no, email n quntity in da db so hw da admin cn noe wt food the user order.....now i wan all da info enter in db so tat admin cn all da info n deliver da food....i aso got prob wt the roll back function,1 user cnt make another order if he make there will an error sign...can anybody help me...i really2 need it urgently....10q..
<?php $debug = true; //variable to commit transaction $commit = "commit"; $errors = array(); /* fetch data from form input */ extract ($_POST); /* connect to server */ if(!$db = mysql_connect("localhost", "root", "")) { $errors[] = mysql_error(); } /* select database */ if(!mysql_select_db("webauth", $db)) { $errors[] = mysql_error(); } //begin transaction if(!mysql_query("begin")) { $errors[] = mysql_error(); } /* fields' names in the database */ [U]$result = "INSERT INTO buy (id,type,price,desc,email,apartment,roomno,qty)"; [/U] /* variable name as declared as above to be entered to the field */ [U]$result .= "VALUES ('$id','$type','$price','$desc','$email','$apartment','$roomno','$qty')";[/U] if(!mysql_query($result, $db)) { $commit = "rollback"; $errors[] = mysql_error(); } // $commit = "rollback"; //uncomment to automatically rollback the transaction if($commit == "commit") { mysql_query($commit); echo "successful"; echo "<br>"; echo "<a href=order.php>Home</a>"; mysql_close($db); } else { echo "there was an error in your transaction, transction rolled back: "; if($debug == true) { foreach($errors as $value) { echo "<p>" . $value . "</p>"; } } mysql_query($commit); mysql_close($db); } /* variable name as declared as above to be entered to the field */ /* fields' names in the database */ /* execute the query */ ?>