<?php
session_start();
require_once('../conexion.php');
require_once('../include/sesiones.php');

$mar_id_mod=ucfirst(limpiar($_POST['id']));
$mar_nombre=strtoupper(limpiar($_POST['nombre']));
$nameimagen = $_FILES['imagen_marca']['name'];
$tmpimagen = $_FILES['imagen_marca']['tmp_name'];
$extimagen = pathinfo($nameimagen);
$ext = array("","jpg","jpeg","png","jfif","gif","tif","tiff");
$urlnueva = "../img/marca/".$mar_id_mod.".jpg";
if(is_uploaded_file($tmpimagen))
{
    if(array_search($extimagen['extension'],$ext))
    {
        copy($tmpimagen, $urlnueva);
    }
    else 
    {
        echo '<div class="alert alert-danger alert-dismissable">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
          <strong>La imagen no se modifico! </strong> Solo se permiten imágenes con formato  jpg.
        </div>';
    }
}

$sql=mysqli_query($con,"UPDATE marca Set
                    mar_nombre='$mar_nombre'
                    Where mar_id='$mar_id_mod'") or  die(mysqli_error($con)); 

echo '<div class="alert alert-success alert-dismissable">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
        <strong>Marca!</strong> Modificada correctamente.
    </div>';

?>