Advertisement
mrsteveita

first image database upload

May 28th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1.                 <?php if(!isset ($_POST['invia'])){ ?>
  2.                 <form id="firstimg" method="POST">
  3.                 <div class="module_content">
  4.                     <fieldset>
  5.                         <label>Seleziona articolo</label>
  6.                         <select for="article">
  7.                             <option value="" disabled="disabled" selected="selected">-</option>
  8.                             <?php
  9.                             $res=mysql_query("SELECT post_title FROM wp_posts WHERE post_status='publish' AND post_type='post' ORDER BY post_date DESC");
  10.                             if($res && mysql_num_rows($res)>0){
  11.                                 while($row=mysql_fetch_assoc($res)){
  12.                                     $titolo=$row['post_title'].""; ?>
  13.                                     <option value="<?php echo $titolo; ?>"><?php echo $titolo; ?></option>
  14.                             <?php }
  15.                             } else { ?>
  16.                                 <option value="" disabled='disabled'>Errore Connessione</option>
  17.                             <?php } ?>
  18.                         </select>
  19.                     </fieldset>
  20.                     <fieldset>
  21.                         <label>URL Immagine</label>
  22.                         <input type="text" name="img" id="img">
  23.                     </fieldset><div class="clear"></div>
  24.                 </div>
  25.                 <footer>
  26.                     <div class="submit_link">
  27.                         <input type="submit" name="invia" id="invia" value="Invia" class="alt_btn">
  28.                     </div>
  29.                 </footer>
  30.                 </form>
  31.                 <?php
  32.                 } else { ?>
  33.                 <div class="module_content">
  34.                 <fieldset>
  35.                 <?php
  36.                     $article = mysql_real_escape_string($_POST['article']);
  37.                     $img = mysql_real_escape_string($_POST['img']);
  38.                     if($article == "" || $img == ""){
  39.                         echo "Devi riempire tutti i campi";
  40.                     } else {
  41.                         $inviaimg=mysql_query("INSERT INTO wp_posts (post_firstimg) VALUES ('$img') WHERE post_title='$article'");
  42.                         if($inviaimg){
  43.                             echo "Immagine caricata";
  44.                         } else {
  45.                             echo "Caricamento fallito";
  46.                         }
  47.                     } ?>
  48.                     </fieldset>
  49.                     </div>
  50.             <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement