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 */
 
       
      ?>
Shanti C commented: don't use chat room language... +2

Recommended Answers

All 3 Replies

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.

For this , you already have all the information ordered in your database...Them you just make an admin control panel part,where admin can see all the orders and provide with an option delivered or rejected..At the admin part also you can get all the ordered information by select query..try..and tel me if any errors....

1 user cnt make another order if he make there will an error sign

For this check with your database table with apartment no,room no and email with today's date,if the have already entered in database ,then indicate "you have already ordered" message...
means that will be something like this:

$r=mysql_query("select * from buy where apartmentno='".$_POST['apnotext']."' and rno='".$_POST['rno']."' and email='".$_POST['email']."'");
$count=mysql_num_rows($r);
if($count>0)
{
$msg="you have already ordered";
}
else
{// write your insert query...

}

For this , you already have all the information ordered in your database...Them you just make an admin control panel part,where admin can see all the orders and provide with an option delivered or rejected..At the admin part also you can get all the ordered information by select query..try..and tel me if any errors....

For this check with your database table with apartment no,room no and email with today's date,if the have already entered in database ,then indicate "you have already ordered" message...
means that will be something like this:

$r=mysql_query("select * from buy where apartmentno='".$_POST['apnotext']."' and rno='".$_POST['rno']."' and email='".$_POST['email']."'");
$count=mysql_num_rows($r);
if($count>0)
{
$msg="you have already ordered";
}
else
{// write your insert query...

}

hai Ms.Shanti
10x 4ur idea...ive try it but i still get an error....i try 2 5n out....do u have any other option or any other example of script that i can use....im lookin forward ur reply..10x ...

hello..
As some one and me already said...please use proper english..other wise nobody can try to read your thread....
i also...
please post your reply with good english again..
i will definatly get you the information..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.