<style>


.wrapper {
  padding: 5px;
  max-width: 960px;
  width: 95%;
  margin: 20px auto;
}

header {
  padding: 0 15px;
}

.columns {
  display: flex;
  flex-flow: row wrap;
  justify-content: center;
  margin: 5px 0;
}

.column {
  flex: 1;
  border: 0px solid gray;
  margin: 2px;
  padding: 10px;
}
.column:first-child {
  margin-left: 0;
}
.column:last-child {
  margin-right: 0;
}


@media screen and (max-width: 980px) {
  .columns .column {
    margin-bottom: 5px;
    flex-basis: 40%;
  }
  .columns .column:nth-last-child(2) {
    margin-right: 0;
  }
  .columns .column:last-child {
    flex-basis: 100%;
    margin: 0;
  }
}
@media screen and (max-width: 680px) {
  .columns .column {
    flex-basis: 100%;
    margin: 0 0 5px 0;
  }
}
</style><?php
require('conexion.php');
session_start();
$session_id='1'; //$session id
$path = "chicas/";
$categoria_girl=$_POST['categoria_girl'];
$nbchica=$_POST['nb_chica'];
$nb_chica = strtoupper($nbchica);
$nacionalidad=$_POST['nacionalidad'];
$vive_girls=$_POST['vive_girls'];
$edad_girl=$_POST['edad_girl'];
$estatura_girls=$_POST['estatura_girls'];
$idiomas_girl=$_POST['idiomas_girl'];
$descripcion_girl=$_POST['descripcion_girl'];

if(!isset($categoria_girl)|| $categoria_girl=='Insertar Ej: Carme') {
 exit('<font style="background-color:#F00" color="#FFFFFFR" face="Arial Black">FALTA EL CAMPO CATEGOR&Iacute;AS</font><BR>');
 }
 if(!isset($nb_chica)|| $nb_chica=='Insertar Ej: Carme') {
 exit('<font style="background-color:#F00" color="#FFFFFFR" face="Arial Black">FALTA EL CAMPO NOMBRE</font><BR>');
 }
if(!isset($nacionalidad)|| $nacionalidad=='Seleccione') {
 exit('<font style="background-color:#F00" color="#FFFFFFR" face="Arial Black">FALTA EL CAMPO NACIONALIDAD</font><BR>');
 }
	$valid_formats = array("jpg", "png", "gif", "jpeg", "bmp", "mp4", "MP4", "JPG", "PNG", "GIF", "BMP", "JPEG");
	if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
		{
			$name = $_FILES['img_servs']['name'];
			$size = $_FILES['img_servs']['size'];
			if(strlen($name))
				{
				list($txt, $ext) = explode(".", $name);
					if(in_array($ext,$valid_formats))
					{
							$actual_image_name = time().substr(str_replace(" ", "_", $txt), 5).".".$ext;
							$tmp = $_FILES['img_servs']['tmp_name'];
							if(move_uploaded_file($tmp, $path.$actual_image_name))
								{
									
				$result_img=mysqli_query($link,"select * FROM girls_camermodels WHERE nb_girls='$nb_chica'"); 
                        $resultado=mysqli_num_rows($result_img);
					   /* IF($resultado>=1){
						
					      //  exit('<font style="background-color:#F00" color="#FFFFFFR" face="Arial Black">YA EXISTE EL NOMBRE DE LA CHICA</font><br />');   
					   }*/
									
									
$nrosexcs=0;

if($resultado ==0){
    echo 'SE HACE EL REGISTRO';
    $result=mysqli_query($link,"insert into girls_camermodels(categ_girls,nb_girls,nac_girls)values('$categoria_girl','$nb_chica','$nacionalidad')"); 
       $resultnb=mysqli_query($link,"select id_girls,categ_girls FROM girls_camermodels WHERE categ_girls='$categoria_girl' AND nb_girls='$nb_chica' AND nac_girls='$nacionalidad' "); 
        $resultadonbs=mysqli_fetch_array($resultnb);
        $id_girls=$resultadonbs['id_girls'];
        $categ_girls_ext=$resultadonbs['categ_girls'];
           $result=mysqli_query($link,"insert into excursion_img(ext_img,id_girls,url_excimg)values('$ext','$id_girls','chicas/$actual_image_name')");
}else{
     echo 'YA SE HIZO EL REGISTRO';
   // $result=mysqli_query($link,"insert into girls_camermodels(categ_girls,slogan_excursion,fecha_excursion)values('$categoria_client','$nb_slogan','')"); 
       $resultnb=mysqli_query($link,"select id_girls,categ_girls FROM girls_camermodels WHERE categ_girls='$categoria_girl' AND nb_girls='$nb_chica' AND nac_girls='$nacionalidad'"); 
        $resultadonbs=mysqli_fetch_array($resultnb);
        $id_girls=$resultadonbs['id_girls'];
        $categ_girls_ext=$resultadonbs['categ_girls'];
           $result=mysqli_query($link,"insert into excursion_img(ext_img,id_girls,url_excimg)values('$ext','$id_girls','chicas/$actual_image_name')");
}

/*
$resultnb=mysqli_query($link,"select id_girls,img_excursion,categ_girls FROM girls_camermodels WHERE categ_girls='$categoria_client' ORDER BY id_girls DESC LIMIT 10 "); 
$resultadonbs=mysqli_fetch_array($resultnb);
$id_girls=$resultadonbs['id_girls'];
$categ_girls_ext=$resultadonbs['categ_girls'];
  if($categ_girls_ext==$categoria_client){
     $categ_girls_ext.'//'.$categoria_client;
      $result=mysqli_query($link,"insert into excursion_img(categ_girls,id_girls,url_excimg)values('$categoria_client','$id_girls','chicas/$actual_image_name')");
  }else{
     $result=mysqli_query($link,"insert into girls_camermodels(categ_girls,slogan_excursion,img_excursion,fecha_excursion)values('$categoria_client','$nb_slogan','','')"); 
     $result=mysqli_query($link,"select id_girls,img_excursion FROM girls_camermodels WHERE categ_girls='$categoria_client' ORDER BY id_girls DESC LIMIT 10 "); 
     $resultado=mysqli_fetch_array($result);
     $id_girls=$resultado['id_girls'];
     
     $result=mysqli_query($link,"insert into excursion_img(categ_girls,id_girls,url_excimg)values('$categoria_client','$id_girls','chicas/$actual_image_name')");
      
  }

*/
 
       $resultnb=mysqli_query($link,"select id_girls,categ_girls FROM girls_camermodels WHERE categ_girls='$categoria_girl' AND nb_girls='$nb_chica' AND nac_girls='$nacionalidad'"); 
        $resultadonbs=mysqli_fetch_array($resultnb);
        $id_girls=$resultadonbs['id_girls'];
        
$result=mysqli_query($link,"select ext_img,url_excimg,id_girls FROM excursion_img WHERE id_girls='$id_girls'"); 
echo '<section class="columns">';
/*<div class="cardexcs">
             <div class="cardexc">*/
while($resultado=mysqli_fetch_array($result)){
	$nrosexcs++;
$ext_img=$resultado['ext_img'];
$id_girls=$resultado['id_girls'];
$img_excursions=$resultado['url_excimg'];
if($ext_img=='mp4' or $ext_img=='MP4'){
	
	echo '<div class="column">';
					
		echo "<input name='img_foto' type='hidden' id='img_foto' value='chicas/$actual_image_name' />";
		echo "<input name='id_girls_img' type='hidden' id='id_girls_img' value='$id_girls' />";
		echo "<video src='$img_excursions' width='160' height='160' controls></video><br>";
		echo "<input name='imagenexci' type='radio' id='imagenexci' value='".$id_girls."' onclick='imagenexc(this);eliminarexcursionimg();'/>";
		//echo "<img src='img/borrar22.png' border='0' onclick='imagenexc(this);'/>";
		//echo "<img src='img/borrar22.png' border='0' onclick='eliminarexcursimg();'/>";
		
		echo '</div>';
	
}else{
	
	echo '<div class="column">';
					
		echo "<input name='img_foto' type='hidden' id='img_foto' value='chicas/$actual_image_name' />";
		echo "<input name='id_girls_img' type='hidden' id='id_girls_img' value='$id_girls' />";
		echo "<img src='$img_excursions' border='0' width='160' height='160'/><br>";
		echo "<input name='imagenexci' type='radio' id='imagenexci' value='".$id_girls."' onclick='imagenexc(this);eliminarexcursionimg();'/>";
		//echo "<img src='img/borrar22.png' border='0' onclick='imagenexc(this);'/>";
		//echo "<img src='img/borrar22.png' border='0' onclick='eliminarexcursimg();'/>";
		
		echo '</div>';
	
}

					
		
								}//FIN DEL WHILE IMAGENES prueba123
						//echo '</div>';
						echo '</section>';
								}
							else
		echo '<font style="color:#F00;font-size:10px;font-family:Arial Black;">TAMA&Ntilde;O NO PERMITIDO.</font>';
						}
						else
		echo '<font style="color:#F00; font-size:10px; font-family:Arial Black;">INVALIDO EL FORMATO.</font>';		
				}
			else
		echo '<font style="color:#F00; font-size:10px; font-family:Arial Black;">SELECCIONE LA FOTO.</font>';
			exit;
		}

?>