Add Insert a record on submit form

Hi folks,

I am trying to get a form that currently uploads and resizes an image to also insert a record and I have no idea how to make it happen.

here’s the form


<form action="<?php echo $GP_uploadAction; ?>" method="post" enctype="multipart/form-data" name="frm_upload" id="frm_upload" onSubmit="checkFileUpload(this,'',true,5000,'','','','','','');showProgressWindow('fileCopyProgress.htm',300,100);return document.MM_returnValue">
<table width="444" border="0" align="center" cellpadding="10" cellspacing="0">
              <tr>
                <td width="131" class="bodyblue"><div align="right">Select Photo</div></td>
                <td width="273"><input name="fileField" type="file" id="fileField" onChange="checkOneFileUpload(this,'',true,5000,'','','','','','')"></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><div align="right">
                  <input type="submit" name="button" id="button" value="Upload">
                </div></td>
              </tr>
              <tr>
                <td><input name="gallery_no" type="hidden" id="gallery_no" value="6">
                  <input name="photo" type="hidden" id="photo" value="<?php echo $_FILES['name'];?>"></td>
                <td>&nbsp;</td>
              </tr>
</table>
 </form>


and here is what I need to happen at the same time:


  $insertSQL = sprintf("INSERT INTO photos_nwworp (gallery_no, photo) VALUES (%s, %s)",
                       GetSQLValueString($_POST['gallery_no'], "int"),
                       GetSQLValueString($_POST['photo'], "text"));


Can anyone point me in the right direction?

cheers

Dave

Okay,

as a workaround I thought maybe I could forward the page as normal and then include a form with hidden fields to insert the record on that page.

So I googled to automatically submit the form on page load and g0t this.

<script type=“text/javascript”>
window.onload=document.frm_addImageToDbase.submit();
</script>

which I put just under the form.

A step forward I think but with one major problem.
It inserts hundreds and hundreds of blank records. If I can just get it to submit one record I could refine it so it actually enters the correct data.

Got that to work quite nicely.

used

<script type=“text/javascript”>
document.getElementById(‘frm_addImageToDbase’).submit();
</script>

To submit the form and it only submits once now.
A bit of a messy solution I guess but it works.