
<?php

include_once'conection.php';


 $cons_enc = $_POST['encuesta'];
 $pregunta = $_POST['pregunta'];
 
 
    $sql = $connection->prepare("select orden from preguntas where cons_enc = $cons_enc order by orden desc limit 1");
    $sql->execute();
    $orden = $sql->fetch(PDO::FETCH_ASSOC); 

    $ord = $orden["orden"];
    $ord = $ord+1 ;

    $insert = $connection->prepare("INSERT INTO preguntas (pregunta, orden, cons_enc) 
                                    VALUES ('$pregunta', '$ord', $cons_enc)");
    $insert->execute();



   
  if($insert){
    //$_SESSION['toas']=1;
    echo 1;
  }





?>

