Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php session_start();
- $dbhost = "localhost";
- $dbname = "tires";
- $dbuser = "root";
- $dbpass = "swork";
- mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
- mysql_select_db($dbname) or die(mysql_error());
- $edit = $_SESSION['edit'];
- $id_noticia_principal = $_POST['id_noticia_principal'];
- $titulo = $_POST['titulo'];
- $categoria_noticia = $_POST['categoria_noticia'];
- $data = $_POST['dia'] ."/". $_POST['mes'] ."/". $_POST['ano'];
- $descricao_resumida = $_POST['descricao_resumida'];
- $descricao_completa = $_POST['descricao_completa'];
- $dir = "imagem/";
- $ext = array("gif","jpg","png");
- $campos = 1;
- if (isset($_POST['submit'])) {
- $f_name = $_FILES['file']['name'];
- $f_tmp = $_FILES['file']['tmp_name'];
- $f_type = $_FILES['file']['type'];
- $cont=0;
- for($i=0;$i<$campos;$i++){
- $name = $f_name[$i];
- $nome_imagem = md5(uniqid(time())) . "." . $ext[1];
- if ( ($name!="") and (is_file($f_tmp[$i])) and (in_array(substr($name,
- -3),$ext)) ) {
- $up = move_uploaded_file($f_tmp[$i], $dir. "/" . $nome_imagem);
- if ($up==true):
- $sql = "UPDATE noticias_principais SET titulo='". $titulo ."', categoria_noticia='". $categoria_noticia ."', data='". $data ."', descricao_resumida='". $descricao_resumida ."', descricao_completa='". $descricao_completa ."', imagem='". $nome_imagem ."'
- WHERE id_noticia_principal='". $id_noticia_principal ."'";
- $update = mysql_query($sql) or die("Query Error: ".mysql_error());
- include 'alteracao_sucess_header.php';
- $cont++;
- endif;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement