I need a bit of help with the logic of this, please.
I have 2 forms. The one form has text fields and drop downs that have be filled in e.g.: product name, price, category etc.
Then next to it I have another form with the ability to upload a single image which is meant to be a featured image.
When I click submit I want to be able to check that an image has been selected and uploaded. But the problem is that the image has it's own form with it's own upload button that needs to be pressed.
So, if I click on submit to add a product, it is only checking that the submit button was pressed and not that the upload button had already been pressed. Not sure if I am making any sense as it's hard to explain. I will post some code which might help.
here is an example of some of the validation for the main form with all the details of the product with a button name of "add_product"
$message .= "Product name required <br />";
$message .= "Category required <br />";
The upload form:
<form id="form" action="ajaxupload.php" method="post" enctype="multipart/form-data">
<input id="uploadImage" type="file" accept="image/*" name="image" class="form-control" />
<input type="submit" id="button" name="upload" class="btn btn-fill btn-danger" value="Upload" />
I thought about putting the image upload into the same form so they were both in 1 form but it isn't possible because the form with the image upload posts to ajaxupload.php and the other form is going to submit to the database.