Advertisement
Guest User

Untitled

a guest
Jan 19th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <?php
  2. include("includes/db.php");
  3. include("includes/functions.php");
  4.  
  5. if($_REQUEST['command']=='update'){
  6. $name=$_REQUEST['name'];
  7. $email=$_REQUEST['email'];
  8. $address=$_REQUEST['address'];
  9. $phone=$_REQUEST['phone'];
  10.  
  11. $result=mysqli_query($db, "INSERT INTO customers VALUES('','$name','$email','$address','$phone')");
  12. $customerid=mysqli_insert_id();
  13. $date=date('Y-m-d');
  14. $result=mysqli_query("INSERT INTO orders VALUES('','$date','$customerid')");
  15. $orderid=mysqli_insert_id();
  16.  
  17. $max=count($_SESSION['cart']);
  18. for($i=0;$i<$max;$i++){
  19. $pid=$_SESSION['cart'][$i]['productid'];
  20. $q=$_SESSION['cart'][$i]['qty'];
  21. $price=get_price($pid);
  22. mysqli_query($db, "INSERT INTO order_detail VALUES($orderid,$pid,$q,$price)");
  23. }
  24. die('Thank You! your order has been placed!');
  25. }
  26. ?>
  27. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  28. <html xmlns="http://www.w3.org/1999/xhtml">
  29. <head>
  30. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  31. <title>Billing Info</title>
  32. <script language="javascript">
  33. function validate(){
  34. var f=document.form1;
  35. if(f.name.value==''){
  36. alert('Your name is required');
  37. f.name.focus();
  38. return false;
  39. }
  40. f.command.value='update';
  41. f.submit();
  42. }
  43. </script>
  44. </head>
  45.  
  46.  
  47. <body>
  48. <form name="form1" onsubmit="return validate()">
  49. <input type="hidden" name="command" />
  50. <div align="center">
  51. <h1 align="center">Billing Info</h1>
  52. <table border="0" cellpadding="2px">
  53. <tr><td>Order Total:</td><td><?=get_order_total()?></td></tr>
  54. <tr><td>Your Name:</td><td><input type="text" name="name" /></td></tr>
  55. <tr><td>Address:</td><td><input type="text" name="address" /></td></tr>
  56. <tr><td>Email:</td><td><input type="text" name="email" /></td></tr>
  57. <tr><td>Phone:</td><td><input type="text" name="phone" /></td></tr>
  58. <tr><td>&nbsp;</td><td><input type="submit" value="Place Order" /></td></tr>
  59. </table>
  60. </div>
  61. </form>
  62. </body>
  63. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement