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

$fam_id=ucfirst(limpiar($_POST['id']));
$fam_nombre=strtoupper(limpiar($_POST['nombre']));


$nameimagen = $_FILES['imagen_cate']['name'];
$tmpimagen = $_FILES['imagen_cate']['tmp_name'];
$extimagen = pathinfo($nameimagen);
$ext = array("","jpg","jpeg","png","jfif","gif","tif","tiff");
$urlnueva = "../img/categorias/".$fam_id.".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 familias Set fam_nombre='$fam_nombre' Where fam_id='$fam_id'") 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>Familia!</strong> Modificada correctamente.
</div>';

?>

