home *** CD-ROM | disk | FTP | other *** search
/ csi.uticak12.org / csi.uticak12.org.tar / csi.uticak12.org / back / photos_add.php < prev    next >
PHP Script  |  2011-10-20  |  3KB  |  102 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. $fvideo=addslashes($fvideo);
  9.  
  10. $query=mysql_query("INSERT INTO `gal_photos` (`video`, `cat_id`, `title`, `approved`) VALUES ('$fvideo', '$fcat_id', '$ftitle', '$fapproved')") or die (mysql_error());
  11. $photo_id=mysql_insert_id();
  12.  
  13. $filename=$_FILES['bpic2']['tmp_name'];
  14. if ($filename!="") {
  15. if (file_exists('photos/photo_'.$photo_id.'.jpg')) {unlink ('photos/photo_'.$photo_id.'.jpg');};
  16. copy ($filename, 'photos/photo_'.$photo_id.'.jpg'); 
  17. };
  18.  
  19. echo '<script>location.href="photos.php?cat_id='.$cat_id.'&title='.$title.'"</script>';
  20. };
  21.  
  22. ?>
  23.  
  24.  
  25. <?    $header = "Photos - Add entry";
  26.     include ('top.inc'); ?>
  27.  
  28.  
  29. <form action="photos_add.php?pn=<?=$pn?>&cat_id=<?=$cat_id?>&title=<?=$title?>" method="post" name="form1" ENCTYPE="multipart/form-data">
  30. <table border=0 cellspacing=0 cellpadding=5 align=center width="100%">
  31.     <tr>
  32.         <td class="border">
  33.             <table border=0 cellspacing=1 cellpadding=5 width="100%" class="back">
  34.                 <tr>
  35.                     <td class="th" colspan=2><p align="center">Photo</p></td>
  36.                 </tr>
  37.                 <tr>
  38.                     <td class="even" align=right width="40%"><b>Approved:</b></td>
  39.                     <td class="even"><input type="checkbox" name="fapproved" value="1" <? if ($fapproved=='1') {echo 'checked';};?>></td>
  40.                 </tr>
  41.                 <tr>
  42.                     <td width="40%" align="right" class="odd"><strong>Title:</strong></td>
  43.                     <td class="odd"><input type="text" size="70" class="inp" name="ftitle" value="<?=$ftitle?>"></td>
  44.                 </tr>
  45.                 <tr>
  46.                     <td class="even" align=right width="40%"><b>Gallery:</b></td>
  47.                     <td class="even" align="left">
  48.                         <select name="fcat_id" class="inp">
  49.                         <option value="">-- please select --</option>
  50.  
  51. <?
  52. $res=mysql_query("SELECT * FROM `gal_cats` ORDER BY `title`");
  53. while ($f=mysql_fetch_array($res)) {
  54. if ($cat_id==$f['id']) {$add="selected";} else {$add="";};
  55. echo '<option value="'.$f['id'].'" '.$add.'>'.stripslashes(ucfirst(strtolower($f['title']))).'</option>'; 
  56. };
  57. ?>
  58.                         </select>
  59.                     </td>
  60.                 </tr>
  61.                 <tr>
  62.                     <td colspan="2" align="center" class="odd">
  63.                             <img src="
  64. <?
  65. if (file_exists("photos/photo_".$id.".jpg")) {
  66. echo "photos/photo_".$id.".jpg";} else {
  67. echo "int/0.gif";
  68. };
  69. ?>
  70.  
  71.                                                     " alt="" height="100" name="img_big2" border="1"><br><br>
  72.                     </td>
  73.                 </tr>
  74.                 <tr>
  75.                     <td class="even" align=right width="40%">
  76.                         <b>Browse image:</b>
  77.                     </td>
  78.                     <td class="even">
  79.                         <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;}">
  80.                     </td>
  81.                 </tr>
  82.                 <tr>
  83.                     <td width="40%" align="right" class="odd"><strong>Video HTML code:</strong></td>
  84.                     <td class="odd"><textarea cols="70" rows="5" class="inp" name="fvideo"><?=$fvideo?></textarea></td>
  85.                 </tr>
  86.  
  87.  
  88.                 <tr>
  89.                     <td class="tf" align=center colspan="2">
  90.                     <input type=submit class="btn" value="Save"> 
  91.                     <input type=button class="btn" value="Cancel" onClick="location.href='photos.php?pn=<?=$pn?>&cat_id=<?=$cat_id?>&title=<?=$title?>'">
  92.                     </td>
  93.                 </tr>
  94.             </table>
  95.         </td>
  96.     </tr>
  97. </table>
  98.  
  99. <input type="hidden" name="act" value="1">
  100. </form>
  101.  
  102. <? include ('btm.inc'); ?>