Advertisement
Guest User

Untitled

a guest
May 21st, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php session_start();
  2.  
  3.  
  4. $dbhost = "localhost";
  5. $dbname = "tires";
  6. $dbuser = "root";
  7. $dbpass = "swork";
  8.  
  9. mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
  10. mysql_select_db($dbname) or die(mysql_error());
  11.  
  12. $edit = $_SESSION['edit'];
  13. $id_noticia_principal = $_POST['id_noticia_principal'];
  14. $titulo = $_POST['titulo'];
  15. $categoria_noticia = $_POST['categoria_noticia'];
  16. $data = $_POST['dia'] ."/". $_POST['mes'] ."/". $_POST['ano'];
  17. $descricao_resumida = $_POST['descricao_resumida'];
  18. $descricao_completa = $_POST['descricao_completa'];
  19. $dir = "imagem/";
  20. $ext = array("gif","jpg","png");
  21. $campos = 1;
  22.  
  23.  
  24.  if (isset($_POST['submit'])) {
  25.  
  26.  
  27.  
  28. $f_name = $_FILES['file']['name'];
  29. $f_tmp = $_FILES['file']['tmp_name'];
  30. $f_type = $_FILES['file']['type'];
  31. $cont=0;
  32. for($i=0;$i<$campos;$i++){
  33. $name = $f_name[$i];
  34. $nome_imagem = md5(uniqid(time())) . "." . $ext[1];
  35.   if ( ($name!="") and (is_file($f_tmp[$i])) and (in_array(substr($name,
  36. -3),$ext)) ) {  
  37.       $up = move_uploaded_file($f_tmp[$i], $dir. "/" . $nome_imagem);
  38.         if ($up==true):
  39.              $sql = "UPDATE noticias_principais SET titulo='". $titulo ."', categoria_noticia='". $categoria_noticia ."', data='". $data ."', descricao_resumida='". $descricao_resumida ."', descricao_completa='". $descricao_completa  ."', imagem='". $nome_imagem  ."'
  40. WHERE id_noticia_principal='". $id_noticia_principal ."'";
  41. $update = mysql_query($sql) or die("Query Error: ".mysql_error());
  42.  
  43.  
  44.  
  45.         include 'alteracao_sucess_header.php';
  46.        
  47.  
  48.  
  49.               $cont++;
  50.            
  51.         endif;
  52.        
  53.   }
  54. }
  55.  
  56. }
  57.  
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement