Guest User

Untitled

a guest
Jan 29th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. Error: INSERT INTO orders (userid,username,firstname, lastname, orderdate , address, email, tires, oil, sparks, detailkit, total, tordered, phonenumber, storeid) VALUES ('101','bigfella','admin', '' ,'18:27, 29th January 2018', '', '', '', '','', '' , '0', '0', '','Choose...' )
  2. Duplicate entry 'admin' for key 'name'
  3.  
  4. <form action="process.php" method="post">
  5. <div class="form-row">
  6. <div class="form-group col-md-6">
  7. <label class="cblack" for="firstname">First Name:</label>
  8. <input type="text" class="form-control" id="firstname" name="firstname" placeholder="First Name">
  9. </div>
  10. <div class="form-group col-md-6">
  11. <label class="cblack" for="lastname">Last Name:</label>
  12. <input type="text" class="form-control" id="lastname" name="lastname" placeholder=" Last Name">
  13. </div>
  14.  
  15. <div class="form-group col-md-6">
  16. <label class="cblack" for="email">Email Address:</label>
  17. <input type="email" class="form-control" id="email" name="email" placeholder="Email Address">
  18. </div>
  19. <div class="form-group col-md-6">
  20. <label class="cblack" for="phonenumber">Phone Number:</label>
  21. <input type="text" class="form-control" id="phonenumber" name="phonenumber" placeholder="503-555-0000">
  22. </div>
  23. </div>
  24. <div class="form-group">
  25. <label class="cblack" for="address">Shipping Address:</label>
  26. <input type="text" class="form-control" id="address" name="address" placeholder="455 Your Address Here ">
  27. </div>
  28.  
  29. <div class="form-row">
  30. <div class="form-group col-md-2">
  31. <label class="cblack" for="tires">Tires:</label>
  32.  
  33. <input type="text" class="form-control" name="tireqty" id="tires" placeholder="0">
  34. </div>
  35.  
  36. <div class="form-group col-md-2">
  37. <label class="cblack" for="oil">Oil:</label>
  38. <input type="text" class="form-control" name="oilqty" id="oil" placeholder="0">
  39. </div>
  40.  
  41. <div class="form-group col-md-2">
  42. <label class="cblack" for="sparks">Spark Plugs:</label>
  43. <input type="text" class="form-control" name="sparkqty" id="sparks" placeholder="0">
  44. </div>
  45.  
  46. <div class="form-group col-md-2">
  47. <label class="cblack" for="detailkit">Detailing Kits:</label>
  48. <input type="text" class="form-control" name="detailkit" id="detailkit" placeholder="0">
  49. </div>
  50. </div>
  51. </div>
  52. <button type="submit" id="submit" name="submit" class="btn btn-primary">Submit Your Order.</button>
  53. </form>
  54.  
  55. $phonenumber = $_POST['phonenumber'];
  56. $detailkit = $_POST['detailkit'];
  57. $firstname = $_POST['firstname'];
  58. $lastname = $_POST['lastname'];
  59.  
  60. $totalqty = $tireqty + $oilqty + $sparkqty + $detailkit;
  61. $totalamount = 0.00;
  62.  
  63. define('TIREPRICE', 100);
  64. define('OILPRICE', 10);
  65. define('SPARKPRICE', 4);
  66. define('detailkit', 50);
  67.  
  68. $totalamount = $tireqty * TIREPRICE
  69. + $oilqty * OILPRICE
  70. + $detailkit * detailkit
  71. + $sparkqty * SPARKPRICE;
  72. $taxrate = 0.00; // local sales tax is 10%
  73. $totalamount = $totalamount * (1 + $taxrate);
  74.  
  75. //Code Will Insert into database Table.
  76. $servername = "localhost";
  77. $username = "xxxxxx";
  78. $password = 'xxxxxx';
  79. $dbname = "xxxx";
  80.  
  81. // Create connection
  82. $conn = new mysqli($servername, $username, $password, $dbname);
  83. // Check connection
  84. if ($conn->connect_error) {
  85. die("Connection failed: " . $conn->connect_error);
  86. }
  87.  
  88.  
  89. if (isset($_POST['submit'])) { //On Submit Run below code :) For Automotive and then insert into database - AB
  90. $address = $_POST['address'];
  91. $firstname = $_POST['firstname'];
  92. $lastname= $_POST['lastname'];
  93. $email = $_POST['email'];
  94. $tireqty = $_POST['tireqty'];
  95. $oilqty = $_POST['oilqty'];
  96. $sparkqty = $_POST['sparkqty'];
  97. $total = $_POST['total'];
  98. $phonenumber = $_POST['phonenumber'];
  99. $detailkit = $_POST['detailkit'];
  100. $userid = $_SESSION['user']['id'];
  101. $username = $_SESSION['user']['username'];
  102.  
  103.  
  104. $name = $_POST['storeaddress'];
  105. foreach ($name as $storeid){
  106.  
  107. }
  108. $totalqty = $tireqty + $oilqty + $sparkqty + $detailkit;
  109. //$totalordered = $_POST['totalordered'];
  110. $sql = "INSERT INTO orders (userid,username,firstname, lastname, orderdate , address, email, tires, oil, sparks, detailkit, total, tordered, phonenumber, storeid)
  111. VALUES ('$userid','$username','$firstname', '$lastname' ,'$date', '$address', '$email', '$tireqty', '$oilqty','$sparkqty', '$detailkit' , '$totalamount', '$totalqty', '$phonenumber','$storeid' )";
  112.  
  113.  
  114.  
  115. if ($conn->query($sql) === TRUE) {
  116. echo "New record created successfully";
  117. } else {
  118. echo "Error: " . $sql . "<br>" . $conn->error;
  119. }
  120.  
  121. $conn->close();
  122. }
  123.  
  124. ?>
Add Comment
Please, Sign In to add comment