Ver Mensaje Individual
  #3 (permalink)  
Antiguo 04/05/2017, 21:42
Avatar de aviweb2015
aviweb2015
 
Fecha de Ingreso: abril-2016
Ubicación: venezuela
Mensajes: 215
Antigüedad: 8 años, 1 mes
Puntos: 1
Respuesta: duda con llamado de archivo

ok, pety te recuerdas que me dijiste que antes del html va el meto php entonces ese es mi problema que como estoy utilizando alertas si paso el método de registrar arriba del html no me llama las alertas, te anexo el código completo para que veas como lo implemento y el porque de mi pregunta si eso se puede hacer

Código PHP:
Ver original
  1. <!-- la session-->
  2.  
  3. <?php
  4.  
  5.     session_start();
  6.     if(!isset($_SESSION['fk_nivel']))
  7.       {
  8.    
  9.         header('Location: ../index.php?Error=Acceso denegado');
  10. echo "<script>alert('Disculpe Acceso registringido, Usuario no Autorizado')</script>";
  11.  
  12.         exit();
  13.       }
  14.   ?>
  15.  
  16. <!-- fin de la session-->
  17.  
  18.  
  19. <!-- conexion y errores-->
  20. <?php
  21.  
  22. error_reporting( ~E_NOTICE ); // avoid notice
  23. include "../conexion/conexion.php";
  24.  
  25. ?>
  26. <!-- fin conexion y errores-->
  27.  
  28. <!-- proceso para registrar-->
  29. <?php
  30. echo '
  31. <head>
  32. <link rel="stylesheet" href="../css/sweetalert2.min.css">
  33. <link rel="stylesheet" href="../css/sweetalert2.css">
  34. <script src="../js/sweetalert2.js"></script>
  35. <script src="../js/sweetalert2.min.js"></script>
  36. </head>';
  37.  
  38.  
  39.  
  40.   if(isset($_POST['guardar']))
  41.   {
  42.    
  43.     $nombre = $_POST['nombre'];
  44.     $numero = $_POST['numero'];
  45.     $color = $_POST['color'];
  46.     $grupo = $_POST['grupo'];
  47.     $numero_letras = $_POST['numero_letras'];
  48.    
  49.     $imgFile = $_FILES['portada']['name'];
  50.     $tmp_dir = $_FILES['portada']['tmp_name'];
  51.     $imgSize = $_FILES['portada']['size'];
  52.    
  53.    
  54.     if(empty($nombre)){
  55.       $errMSG = "Por favor Ingrese el nombre.";
  56.     }
  57.     else if(empty($numero)){
  58.       $errMSG = "Por favor Ingrese el numero.";
  59.     }
  60.     else if(empty($color)){
  61.       $errMSG = "Por favor Ingrese el color.";
  62.     }
  63.     else if(empty($grupo)){
  64.       $errMSG = "Por favor Indique el grupo al que pertenece.";
  65.     }
  66.     else if(empty($numero_letras)){
  67.       $errMSG = "Por favor Indique la cantidad de letras.";
  68.     }
  69.     else
  70.     {
  71.       $upload_dir = '../galerias_animalitos/'; // upload directory
  72.  
  73.       $imgExt = strtolower(pathinfo($imgFile,PATHINFO_EXTENSION)); // get image extension
  74.    
  75.       // valid image extensions
  76.       $valid_extensions = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions
  77.    
  78.       // rename uploading image
  79.       $portada = rand(1000,1000000).".".$imgExt;
  80.        
  81.       // allow valid image file formats
  82.       if(in_array($imgExt, $valid_extensions)){    
  83.         // Check file size '5MB'
  84.         if($imgSize < 5000000)        {
  85.           move_uploaded_file($tmp_dir,$upload_dir.$portada);
  86.         }
  87.         else{
  88.                    
  89.  
  90. echo "<script>
  91.              swal({
  92.                    title: 'Ups Aviso...',
  93.                    text: '¡ Lo siento, su archivo es demasiado grande !',
  94.                    type: 'info',
  95.                    showConfirmButton: false,
  96.                    allowOutsideClick: false,
  97.                    allowEscapeKey: false,
  98.                    allowEnterKey: false,
  99.                 });
  100.    </script>
  101.    <META HTTP-EQUIV='REFRESH' CONTENT=5;URL=http:registrar_animalitos.php>";
  102.         }
  103.       }
  104.       else{
  105.              
  106. echo "<script>
  107.              swal({
  108.                    title: 'Ups Aviso...',
  109.                    text: '¡ Lo sentimos, sólo se permiten archivos JPG, JPEG, PNG y GIF !',
  110.                    type: 'info',
  111.                    showConfirmButton: false,
  112.                    allowOutsideClick: false,
  113.                    allowEscapeKey: false,
  114.                    allowEnterKey: false,
  115.                 });
  116.      </script>
  117.      <META HTTP-EQUIV='REFRESH' CONTENT=5;URL=http:registrar_animalitos.php>";
  118.       }
  119.     }
  120.    
  121.    
  122.     // si no hay errores continuo...
  123.    
  124.       $sql = $DB_con->prepare('INSERT INTO animalitos (nombre, numero, color, grupo, numero_letras, portada)
  125.      VALUES(:nombre, :numero, :color, :grupo, :numero_letras, :portada)');
  126.       $sql->bindParam(':nombre',$nombre);
  127.       $sql->bindParam(':numero',$numero);
  128.       $sql->bindParam(':color',$color);
  129.       $sql->bindParam(':grupo',$grupo);
  130.       $sql->bindParam(':numero_letras',$numero_letras);
  131.       $sql->bindParam(':portada',$portada);
  132.      
  133.       if($sql->execute())
  134.       {
  135.            
  136. echo "<script>
  137.              swal({
  138.                    title: 'Bien Hecho...',
  139.                    text: '¡ Registro Insertado Correctamente !',
  140.                    type: 'success',
  141.                    showConfirmButton: false,
  142.                    allowOutsideClick: false,
  143.                    allowEscapeKey: false,
  144.                    allowEnterKey: false,
  145.                  });
  146.      </script>
  147.      <META HTTP-EQUIV='REFRESH' CONTENT=5;URL=http:registrar_animalitos.php>";
  148.  
  149.       }
  150.       else
  151.       {
  152.  
  153. echo "<script>
  154.              swal({
  155.                    title: 'Ups Aviso...',
  156.                    text: '¡ Hubo un error al insertar el registro !',
  157.                    type: 'info',
  158.                    showConfirmButton: false,
  159.                    allowOutsideClick: false,
  160.                    allowEscapeKey: false,
  161.                    allowEnterKey: false,
  162.                  });
  163.    </script>
  164.    <META HTTP-EQUIV='REFRESH' CONTENT=5;URL=http:registrar_animalitos.php>";
  165.       }
  166.    
  167.   }
  168. ?>
  169. <!-- fin proceso para registrar-->
  170.  
  171.  
  172. <!DOCTYPE html>
  173. <html lang="es">
  174. <head>
  175.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  176.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  177.     <title>cuál es el dato</title>
  178.    
  179.  
  180. <link rel="icon" href="../mi favicon/cual es el dato.png">
  181.   <!-- CSS  -->
  182.  
  183.  
  184.   <!-- Custom styles for this template -->
  185. <link href="MDicons/css/MDicon.min.css" rel="stylesheet">
  186. <link href="../css/list-inline-social.css" rel="stylesheet">
  187. <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  188. <link href="../css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
  189. <link href="../css/hr.css" type="text/css" rel="stylesheet" media="screen,projection"/>
  190. <link href="../css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
  191.  
  192. </head>
  193.  
  194. <body>
  195.    
  196.  
  197. <!-- menu-->
  198. <?php
  199. include 'menu.php';
  200. ?>
  201. <!-- fin menu-->
__________________
yoclens avilan