home *** CD-ROM | disk | FTP | other *** search
/ csi.uticak12.org / csi.uticak12.org.tar / csi.uticak12.org / back / cats_add.php < prev    next >
PHP Script  |  2011-10-20  |  3KB  |  79 lines

  1. <?
  2. include 'guard.php';
  3. mysql_connect(HostName,UserName,Password) or die("<html><body>Can not connect to MySql server!<br></body></html>");
  4. mysql_select_db (DBName) or die ("<html><body>Could not select database ".DBName."<br></body></html>");
  5.  
  6. if ($act=='1') {
  7. $ftitle=addslashes($ftitle);
  8.  
  9. $res=mysql_query("INSERT INTO `gal_cats` (`title`, `approved`) VALUES ('$ftitle', '$fapproved')") or die (mysql_error());
  10. $id=mysql_insert_id();
  11.  
  12. $filename=$_FILES['bpic2']['tmp_name'];
  13. if ($filename!="") {
  14. if (file_exists('cats/photo_'.$id.'.jpg')) {unlink ('cats/photo_'.$id.'.jpg');};
  15. copy ($filename, 'cats/photo_'.$id.'.jpg'); 
  16. };
  17.  
  18. echo '<script>location.href="cats.php?pn='.$pn.'"</script>';
  19. };
  20. ?>
  21.  
  22. <?    
  23.     $header = "Galleries - Add new";
  24.     include ('top.inc'); 
  25. ?>
  26.  
  27.  
  28. <form action="cats_add.php?pn=<?=$pn?>" method="post" name="form1" ENCTYPE="multipart/form-data">
  29. <table border=0 cellspacing=0 cellpadding=5 align=center width="100%">
  30.     <tr>
  31.         <td class="border">
  32.             <table border=0 cellspacing=1 cellpadding=5 width="100%" class="back">
  33.                 <tr>
  34.                     <td class="th" colspan=2><p align="center">Gallery Details</p></td>
  35.                 </tr>
  36.                 <tr>
  37.                     <td class="even" align=right width="40%"><b>Approved:</b></td>
  38.                     <td class="even"><input type="checkbox" name="fapproved" value="1" <? if ($fapproved=='1') {echo 'checked';};?>></td>
  39.                 </tr>
  40.                 <tr>
  41.                     <td class="odd" align=right width="40%"><b>Title:</b></td>
  42.                     <td class="odd"><input type="text" name="ftitle" value="<?=$ftitle?>" class="inp" size="60"></td>
  43.                 </tr>
  44.                 <tr>
  45.                     <td colspan="2" align="center" class="even">
  46.                             <img src="
  47. <?
  48. if (file_exists("cats/photo_".$id.".jpg")) {
  49. echo "cats/photo_".$id.".jpg";} else {
  50. echo "int/0.gif";
  51. };
  52. ?>
  53.  
  54.                                                     " alt="" height="100" name="img_big2" border="1"><br><br>
  55.                     </td>
  56.                 </tr>
  57.                 <tr>
  58.                     <td class="even" align=right width="40%">
  59.                         <b>Browse thumbnail:</b>
  60.                     </td>
  61.                     <td class="even">
  62.                         <input type="file" size="30" class="inp" name="bpic2" onFocus="if (form1.bpic2.value!='') {document.all['img_big2'].src=form1.bpic2.value; form1.bpic2.value=form1.bpic2.value;}">
  63.                     </td>
  64.                 </tr>
  65.                 <tr>
  66.                     <td class="tf" align=center colspan=2>
  67.                     <input type=submit class="btn" value="Submit">
  68.                     <input type=button class="btn" value="Back" onClick="location.href='cats.php?pn=<?=$pn?>'">
  69.                     </td>
  70.                 </tr>
  71.             </table>
  72.         </td>
  73.     </tr>
  74. </table>
  75.  
  76. <input type="hidden" name="act" value="1">
  77. </form>
  78.  
  79. <? include ('btm.inc'); ?>