Hi
Thank you for your replies. Clearly, in my attempt to keep my post as brief as possible, I have not explained what I am trying to do, so here is a slightly longer version with coding.
Our service is to use employee data provided by individual companies to estimate their liabilities under forthcoming pension legislation. To achieve this, when a company visits our site they register and create a unique id.
To get the data to us, they download from the site an Excel template and complete it with their employee data. This template name has their id in it to prevent others accessing it.
At this point, their unique record in a MySql database has a marker to say they have downloaded the template. So far, so good.
Using this marker, when they return to the Log In page, they are given different instructions and can then upload the template with the data using the page in question called, naturally, ‘employee_data_upload.php’.
I am using phpFileUploader for uploading and this works well. When the upload is complete, the user receives an alert telling them it has been completed successfully. This is generated by a javascript function:
<script type='text/javascript'>
function CuteWebUI_AjaxUploader_OnTaskComplete(task)
{
alert(task.FileName + " has been successfully uploaded. You should now return using the button below and proceed to your Initial Report.");
}
</script>
Now comes the bit I am struggling with. I wish to place a marker on the database that upload has taken place using the following code:
// Connect to the database
$dbc = mysqli_connect('dbxxxxxx.db.1and1.com', 'dboxxxxxx', xxxxxxx', 'dbxxxxxxxx'); (I have replaced the actual database details with xs for security.)
/ check connection /
if (mysqli_connect_error()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();}
$query = "UPDATE CBCcompanies SET xlsx_upload='1' WHERE id = $id";
mysqli_query($dbc, $query); }
This works fine on its own on the page but, of course, fires when the page is opened, whether or not upload takes place. If the user decides not to upload for the moment and returns using a button to the Log In page, the system now thinks uploading has taken place and will provide the wrong information.
Ideally this would be in the above javascript function, but I cannot get it to work in this script.
So I thought I would provide two additional buttons for the user – one allowing them to proceed after upload (to the ‘calculation.php’ page) and one to return to the Log In page without uploading. I am using forms because whichever direction the user chooses, their unique data needs to go with them as I do not want them to go through the log in procedure with their password a second time for the same session, so the coding is:
<form id="form1" name="form1" method="post" action="calculation.php">
<input type="hidden" name="excel" id="excel" value="<?php echo '' . $excel . ''?>" />
<input type="hidden" name="id" id="id" value="<?php echo '' . $id . ''?>" />
<input type="hidden" name="log_in_company_name" id="log_in_company_name" value="<?php echo '' . $log_in_company_name . ''?>" />
<div align="center">
<input type="submit" name="Continue" value="Continue having uploaded your CBC Template" id="Continue" />
</form>
<form id="form2" name="form2" method="post" action="log_in.php">
<input type="hidden" name="excel" id="excel" value="<?php echo '' . $excel . ''?>" />
<input type="hidden" name="id" id="id" value="<?php echo '' . $id . ''?>" />
<input type="hidden" name="log_in_company_name" id="log_in_company_name" value="<?php echo '' . $log_in_company_name . ''?>" />
<div align="center">
<input type="submit" name="Return" value="No - I do not wish to upload - return to Log In page" id="Return" />
</form>
If I place the MySql query in Form 1 or outside it and use
if(isset($_POST['Continue'])) {
the query does not take place. If I change the form action to:
<form id="form2" name="form2" method="post" action=" ">
the query does take place, but the user is not sent to the next page. So there seems to be a conflict between the MySql query and embedding or linking the action to a form.
Is there any coding which can achieve my objectives?
Thanks for help.
Tony