php - Multiple upload buttons on one page -


i wanted have multiple upload buttons on 1 page keeps giving me error on first upload "query empty". second uploader works (s2). here code:

<?  if(isset($_post['s1'])) {  $qset = "select frontimg1 cat"; $rset = mysql_query($qset) or die(mysql_error()); $aset = mysql_fetch_array($rset); unset($aset);       $imagename = $_files['images']['name'];     if(!empty($imagename))         {     $t = time();     $newimagename = "$t$imagename";     copy($_files['images']['tmp_name'], "../img/header_images/$newimagename");     $q1 = "update cat set                      frontimg1='$newimagename'";                      }     mysql_query($q1) or die(mysql_error());      echo "<div class=alert fade in><b>website settings updated successfully!</b>    </div>"; }  elseif(isset($_post['s2'])) {  $qset = "select frontimg2 cat"; $rset = mysql_query($qset) or die(mysql_error()); $aset = mysql_fetch_array($rset); unset($aset);       $imagename = $_files['images']['name'];     if(!empty($imagename))         {     $t = time();     $newimagename = "$t$imagename";     copy($_files['images']['tmp_name'], "../img/header_images/$newimagename");     $q1 = "update cat set                      frontimg2='$newimagename'";                      }     mysql_query($q1) or die(mysql_error());      echo "<div class=alert fade in><b>website settings updated successfully!</b>        </div>"; }  //get main site settings $qset = "select * cat"; $rset = mysql_query($qset) or die(mysql_error()); $aset = mysql_fetch_array($rset);   ?>  <form method=post name=f1 onsubmit="return checksettings();" enctype="multipart/form-data">    <table align=center width="90%" cellpadding="4" cellspacing="1">     <tr>        <td colspan=2 class=header><font size="2">          <b>website settings</b></font></td>     </tr>     <tr>        <td class="form_request">current header image:</td>       <td class="form_answer">         <p><label>            <? if($aset['frontimg1']==""){?>           na            <?}else{?>           <img src="../img/header_images/<?=$aset['frontimg1']?>"> </label></p>         <p><label>            <?}?>           </label></p>       </td>     </tr>     <tr>        <td class="form_request">upload new header image:</td>       <td class="form_answer"><label>          <input type="file" name="images">         <br />         (leave blank keep same image)</label></td>     </tr>     <tr>        <td>&nbsp;</td>       <td>          <input type=submit name=s1 value=save class="btn btn-primary">       </td>     </tr>         <tr>        <td class="form_request">second header image:</td>       <td class="form_answer">         <p><label>            <? if($aset['frontimg2']==""){?>           na            <?}else{?>           <img src="../img/header_images/<?=$aset['frontimg2']?>"> </label></p>         <p><label>            <?}?>           </label></p>       </td>     </tr>     <tr>        <td class="form_request">upload new header image:</td>       <td class="form_answer"><label>          <input type="file" name="images">         <br />         (leave blank keep same image)</label></td>     </tr>     <tr>        <td>&nbsp;</td>       <td>          <input type=submit name=s2 value=save class="btn btn-primary">       </td>     </tr>   </table>  </form> 

any great

your file input fields both have same name (images) s2 override s1. try changing them unique ie imagess1 , imagess2.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -