Basically what I'm trying to do is to get a user to submit his/her order into my database through a form. I can grab the c_id (customer_id) from a php code at the top of the page so there's nothing wrong there.
This is my html for my form.
<form action="tshirtorder.php" method="post" enctype="multipart/form-data"><!-- form Begin -->
<div class="form-group"><!-- form-group Begin -->
<label>Design Image</label>
<input type="file" name="t_image" class="form-control form-height-custom" required>
</div>
<div class="form-group"><!-- form-group Begin -->
<label>Design Name</label>
<input type="text" class="form-control" name="t_name" value="Custom Design" disabled>
</div><!-- form-group Finish -->
<div class="form-group"><!-- form-group Begin -->
<label>Quantity</label>
<input type="text" class="form-control" name="t_qty" required>
</div><!-- form-group Finish -->
<div class="form-group"><!-- form-group Begin -->
<label>Size</label>
<input type="text" class="form-control" name="t_size" required>
</div><!-- form-group Finish -->
<div class="text-center"><!-- text-center Begin -->
<a href="torder.php?c_id=<?php echo $customer_id ?>"><button type="submit" name="tsubmit" class="btn btn-primary">
<i class="fa fa-user-md"></i> Send Message
</button></a>
</div><!-- text-center Finish -->
</form><!-- form Finish -->
Below is my sql statement.
<?php
if(isset($_POST['tsubmit'])){
$customer_id = $_GET['c_id'];
$t_image = $_FILES['t_image']['name'];
$t_image_tmp = $_FILES['t_image']['tmp_name'];
$t_name = $_POST['t_name'];
$due_amount = "25";
$invoice_no = mt_rand();
$t_qty = $_POST['t_qty'];
$t_size = $_POST['t_size'];
$status = "pending";
$pro_id = "$customer_id + 1";
move_uploaded_file($t_image_tmp,"images/customer/customerdesign/$t_image");
$sub_total = "$t_qty*25";
$insert_tshirt_order = "insert into tshirt_orders (customer_id,due_amount,invoice_no,qty,size,order_date,order_status) values ('$customer_id','$sub_total','$invoice_no','$t_qty','$t_size',NOW(),'$status')";
$run_tshirt_order = mysqli_query($conn,$insert_tshirt_order);
$insert_tpending_order = "insert into tpending_order (customer_id,invoice_no,product_id,qty,size,order_status) values ('$customer_id','$invoice_no','$pro_id','$t_qty','$t_size','$status')";
$run_tpending_order = mysqli_query($conn,$insert_tpending_order);
echo "<script>alert('Your T-Shirt Design has been successfully ordered!')</script>";
echo "<script>window.open('profile.php?t_orders','_self')</script>";
}
?>
There are a few attributes in my sql statement that I wish to be added automatically into my database such as the sub total price for the item and the invoice num, date and status.
For some reason, it's just not inserting the values into the database and I've ran through the statement for quite some time now and I can't figure out what is wrong. Hoping to find an answer here. Thank you.
$run_tshirt_orderand$run_tpending_order, if they are false, output the value ofmysqli_error($conn)