How to send variables from one PHP to another and retrieve them to use them?

0

I have a form in which I print variables through a query to my database, I want to send these variables to another php file to be able to use them, I am currently doing it with a form and sent them with the POST method and a submit button , but when wanting to receive them, it sends me an error and says that they are undefined. To explain myself better in this form I print my variables that keep a query in my database, first I make the connections, then I declare my variables and I print them last.

    <?php
     $conexion=mysql_connect("localhost","id6681618_pagina26","aldair1234")
     or die ("Problemas en la conexion");
     mysql_select_db("id6681618_pagina26",$conexion)
     or die("Problemas en la conexion de la base de datos");
     $inscripciones=mysql_query("SELECT CURP
     FROM inscripciones where
     CURP='$_REQUEST[CURP]'",$conexion) or
     die("Problemas en el select:".mysql_error());

     if($reg1=mysql_fetch_array($inscripciones))
     {
      /*$folio=$reg1['FOLIO'];
         $nom=$reg1['NOMBRE'];
         $apellipa=$reg1['APELLIDOPA'];
         $apellima=$reg1['APELLIDOMA'];
         $nac=$reg1['FECHA_NACIMIENTO'];
         $curp=$reg1['CURP'];
         $ecivil=$reg1['ECIVIL'];
         $estadonac=$reg1['CLAVE_ESTADO_NAC'];
         $muninac=$reg1['CLAVE_MUNICIPIO_NAC'];
         $estadovive=$reg1['CLAVE_ESTADO_VIVE'];
         $munivive=$reg1['CLAVE_MUNICIPIO_VIVE'];
         $localidad=$reg1['CLAVE_LOCALIDAD_VIVE'];
         $colonia=$reg1['COLONIA_VIVE'];
         $calle=$reg1['CALLE_VIVE'];
         $cp=$reg1['CP_VIVE'];
         $telcasa=$reg1['TEL_CASA'];
         $celular=$reg1['CELULAR'];
         $correo=$reg1['CORREO'];
         $primera=$reg1['PRIMERA_OPCION'];
         $segunda=$reg1['SEGUNDA_OPCION'];
         $tercera=$reg1['TERCERA_OPCION'];
         $sangre=$reg1['TIPO_SANGUINEO'];
         $nacionalidad=$reg1['NACIONALIDAD'];
         $secu=$reg1['NOMBRE_DE_SECUNDARIA_DE_PROSEDENCIA'];
         $cct=$reg1['CCT_DE_SECUNDARIA'];
         $nombre_tutor_padre=$reg1['NOMBRE_DE_PADRE_O_TUTOR'];
         $ocupacion_tutor_padre=$reg1['OCUPACION_DEL_TUTOR'];
         $numero1=$reg1['NUMERO_1'];
         $numero2=$reg1['NUMERO_2'];*/
       $mensaje = "Este CURP ya fue ingresado, por favor intenta nuevamente.";
     echo "<script>";
     echo "alert('$mensaje');";
     echo "history.back();";
     echo "</script>";

     //redirect('formulario.html', 'refresh');
     //header( "refresh:5;url=formulario.html" );

     }  

    else
     {

     mysql_query("insert into 
     inscripciones(NOMBRE, APELLIDOPA, APELLIDOMA, FECHA_NACIMIENTO, CURP,ECIVIL, CLAVE_ESTADO_NAC, CLAVE_MUNICIPIO_NAC, CLAVE_ESTADO_VIVE, CLAVE_MUNICIPIO_VIVE, CLAVE_LOCALIDAD_VIVE, COLONIA_VIVE, 
    CALLE_VIVE, CP_VIVE, TEL_CASA, CELULAR, CORREO,PRIMERA_OPCION, SEGUNDA_OPCION, TERCERA_OPCION, TIPO_SANGUINEO, 
    NACIONALIDAD, NOMBRE_DE_SECUNDARIA_DE_PROSEDENCIA, CCT_DE_SECUNDARIA, NOMBRE_DE_PADRE_O_TUTOR, OCUPACION_DEL_TUTOR, NUMERO_1, NUMERO_2)values
    ('$_REQUEST[NOMBRE]','$_REQUEST[APELLIDOPA]','$_REQUEST[APELLIDOMA]','$_REQUEST[FECHA_NACIMIENTO]','$_REQUEST[CURP]','$_REQUEST[ECIVIL]','$_REQUEST[CLAVE_ESTADO_NAC]',
    '$_REQUEST[CLAVE_MUNICIPIO_NAC]','$_REQUEST[CLAVE_ESTADO_VIVE]','$_REQUEST[CLAVE_MUNICIPIO_VIVE]','$_REQUEST[CLAVE_LOCALIDAD_VIVE]','$_REQUEST[COLONIA_VIVE]',
    '$_REQUEST[CALLE_VIVE]',$_REQUEST[CP_VIVE],$_REQUEST[TEL_CASA],$_REQUEST[CELULAR],'$_REQUEST[CORREO]','$_REQUEST[PRIMERA_OPCION]','$_REQUEST[SEGUNDA_OPCION]','$_REQUEST[TERCERA_OPCION]',
    '$_REQUEST[TIPO_SANGUINEO]',
    '$_REQUEST[NACIONALIDAD]','$_REQUEST[NOMBRE_DE_SECUNDARIA_DE_PROSEDENCIA]',
    '$_REQUEST[CCT_DE_SECUNDARIA]',
    '$_REQUEST[NOMBRE_DE_PADRE_O_TUTOR]',
    '$_REQUEST[OCUPACION_DEL_TUTOR]',$_REQUEST[NUMERO_1],$_REQUEST[NUMERO_2])",


     $conexion) or die("Problemas en el select".mysql_error());

     $consulta=mysql_query("SELECT FOLIO
     FROM inscripciones where
     CURP='$_REQUEST[CURP]'",$conexion) or
     die("Problemas en el select:".mysql_error());
     if($con=mysql_fetch_array($consulta)){
         $folio=$con['FOLIO'];
     }
     mysql_close($conexion);

     print '<script language="JavaScript">'; 
     print 'alert("Proceso terminado");'; 

     print '</script>'; 

$nom=$_REQUEST['NOMBRE'];
$apellipa=$_REQUEST['APELLIDOPA'];
$apellima=$_REQUEST['APELLIDOMA'];
$nac=$_REQUEST['FECHA_NACIMIENTO'];
$curp=$_REQUEST['CURP'];
$ecivil=$_REQUEST['ECIVIL'];
$estadonac=$_REQUEST['CLAVE_ESTADO_NAC'];
$muninac=$_REQUEST['CLAVE_MUNICIPIO_NAC'];
$estadovive=$_REQUEST['CLAVE_ESTADO_VIVE'];
$munivive=$_REQUEST['CLAVE_MUNICIPIO_VIVE'];
$localidad=$_REQUEST['CLAVE_LOCALIDAD_VIVE'];
$colonia=$_REQUEST['COLONIA_VIVE'];
$calle=$_REQUEST['CALLE_VIVE'];
$cp=$_REQUEST['CP_VIVE'];
$telcasa=$_REQUEST['TEL_CASA'];
$celular=$_REQUEST['CELULAR'];
$correo=$_REQUEST['CORREO'];
$primera=$_REQUEST['PRIMERA_OPCION'];
$segunda=$_REQUEST['SEGUNDA_OPCION'];
$tercera=$_REQUEST['TERCERA_OPCION'];
$sangre=$_REQUEST['TIPO_SANGUINEO'];
$nacionalidad=$_REQUEST['NACIONALIDAD'];
$secu=$_REQUEST['NOMBRE_DE_SECUNDARIA_DE_PROSEDENCIA'];
$cct=$_REQUEST['CCT_DE_SECUNDARIA'];
$nombre_tutor_padre=$_REQUEST['NOMBRE_DE_PADRE_O_TUTOR'];
$ocupacion_tutor_padre=$_REQUEST['OCUPACION_DEL_TUTOR'];
$numero1=$_REQUEST['NUMERO_1'];
$numero2=$_REQUEST['NUMERO_2'];



}

      ?>

Here I print them:

    <h1>Verifica que los datos que ingresaste sean correctos, si así lo es, presiona para generar tu ficha.</h1>


     <form action="Prueba3/reporte.php" method="post" name="Hola">
   <div  class="col-4">
    <label>
      FOLIO 
    <input name="FOLIO" type="text"  disabled="false" value="<?php echo $folio; ?>" />    
    </label>
  </div>

   <div  class="col-4">
    <label>
      NOMBRE
      <input name="NOMBRE" type="text"  disabled="false" value="<?php echo $nom; ?>" />    
      </label>
  </div>


<div class="col-4">
    <label>
      APELLIDO PATERNO
      <input name="APELLIDOPA" type="text" disabled="false" value="<?php echo $apellipa ?>" />
    </label>
  </div>


  <div class="col-4">
    <label>
      APELLIDO MATERNO
      <input name="APELLIDOMA" type="text" disabled="false" value="<?php echo $apellima?>" />
    </label>
  </div>


  <div class="col-3">
    <label>
      FECHA DE NACIMIENTO
      <input name="FECHA_NACIMIENTO" type="text" disabled="false" value="<?php echo $nac ?>" />
    </label>
  </div>


  <div class="col-3">
    <label>
      CURP
      <input name="CURP" type="text" disabled="false" value="<?php echo $curp ?>" />
    </label>
  </div>


  <div class="col-3">
    <label>
      ESTADO CIVIL 
      <input name="ECIVIL" type="text" disabled="false" value="<?php echo $ecivil ?>" />
  </div>


   <div class="col-4">
    <label>
      ESTADO DE NACIMIENTO 
      <input name="CLAVE_ESTADO_NAC" type="text" disabled="false" value="<?php echo $estadonac ?>" />
    </label>
  </div>


  <div class="col-4">
    <label>
      MUNICIPIO DE NACIMIENTO
      <input name="CLAVE_MUNICIPIO_NAC" type="text" disabled="false" value="<?php echo $muninac ?>" />
    </label>
  </div>


   <div class="col-4">
    <label>
      ESTADO DONDE VIVE ACTUALMENTE 
      <input name="CLAVE_ESTADO_VIVE" type="text" disabled="false" value="<?php echo $estadovive ?>" />
    </label>
  </div>


   <div class="col-4">
    <label>
      MUNICIPIO DONDE VIVE ACTUALMENTE 
      <input name="CLAVE_MUNICIPIO_VIVE" type="text" disabled="false" value="<?php echo $munivive ?>" />
    </label>
  </div>


  <div class="col-3">
    <label>
     LOCALIDAD
      <input name="CLAVE_LOCALIDAD_VIVE" type="text" disabled="false" value="<?php echo $localidad ?>" />  
    </label>
  </div>


  <div class="col-3">
    <label>
      COLONIA 
      <input  name="COLONIA_VIVE" type="text" disabled="false" value="<?php echo $colonia ?>" />
    </label>
  </div>


  <div class="col-3">
   <label>
      CALLE 
      <input name="CALLE_VIVE" type="text" disabled="false" value="<?php echo $calle ?>" />
    </label>
  </div>


  <div class="col-4">
    <label>
       CÓDIGO POSTAL 
       <input name="CP_VIVE" type="text" disabled="false" value="<?php echo $cp ?>" />
    </label>
  </div>


  <div class="col-4">
    <label>
      TELÉFONO DE CASA
      <input name="TEL_CASA" type="text" disabled="false" value="<?php echo $telcasa ?>" />
    </label>
  </div>


  <div class="col-4">
    <label>
     CELULAR
     <input name="CELULAR" type="text" disabled="false" value="<?php echo $celular ?>" />
    </label>
  </div>


  <div class="col-4">
    <label>
      CORREO ELECTRÓNICO
      <input name="CORREO" type="text" disabled="false" value="<?php echo $correo ?>" />
    </label>
  </div>


  <div class="col-3">
    <label>
      PRIMERA OPCIÓN
     <input name="PRIMERA_OPCION" type="text" disabled="false" value="<?php echo $primera ?>" />
    </label>
  </div>


  <div class="col-3">
    <label>
     SEGUNDA OPCIÓN
     <input name="SEGUNDA_OPCION" type="text" disabled="false" value="<?php echo $segunda ?>" />
    </label>
  </div>


  <div class="col-3">
    <label>
      TERCERA OPCIÓN 
     <input name="TERCERA_OPCION" type="text" disabled="false" value="<?php echo $tercera ?>" />
  </div>


  <div class="col-4">
    <label>
       TIPO SANGUÍNEO
   <input name="TIPO_SANGUINEO" type="text" disabled="false" value="<?php echo $sangre ?>" />
  </div>


  <div class="col-4">
    <label>
      NACIONALIDAD
   <input name="NACIONALIDAD" type="text" disabled="false" value="<?php echo $nacionalidad ?>" />       
    </label>
  </div>


  <div class="col-4">
    <label>
       NOMBRE DE SECUNDARIA DE PROCEDENCIA
       <input name="NOMBRE_DE_SECUNDARIA_DE_PROSEDENCIA" type="text" disabled="false" value="<?php echo $secu ?>" />
    </label>
  </div>


  <div class="col-4">
    <label>
      CCT DE LA SECUNDARIA DE PROCEDENCIA
      <input name="CCT_DE_SECUNDARIA" type="text" disabled="false" value="<?php echo $cct ?>" />
    </label>
  </div>


  <div class="col-3">
    <label>
      NOMBRE DEL PADRE O TUTOR
      <input  name="NOMBRE_DE_PADRE_O_TUTOR" type="text" disabled="false" value="<?php echo $nombre_tutor_padre ?>" />
    </label>
  </div>


  <div class="col-3">
    <label>
     OCUPACIÓN DEL PADRE O TUTOR
     <input type="text" name="OCUPACION_DEL_TUTOR" disabled="false" value="<?php echo $ocupacion_tutor_padre ?>" />
    </label>
  </div>


  <div class="col-3">
    <label>
       NÚMERO DE CONTACTO 1
       <input name="NUMERO_1" type="number" disabled="false" value="<?php echo $numero1 ?>" />
  </div>


   <div class="col-3">
    <label>
       NÚMERO DE CONTACTO 2
       <input name="NUMERO_2" type="number" disabled="false" value="<?php echo $numero2 ?>" />
  </div>


   <div class="col-3">

  </div>
   <div class="col-3">

  </div>



    <div class="col-3">

  </div>


   <div class="col-3">

  </div>



    <div class="col-3">

  </div>


  <div class="col-submit">
    <input type="submit" class="submitbtn" name="enviar1" value="Generar" >
        <section id="openmodal" class="modalDialog">
            </section>
  </div>
  <!--<div class="col-submit">
    <input type="button" class="submitbtn" name="enviar" value="No" onclick = "this.form.action = 'eliminar.php'; this.form.submit()">
    <section id="openmodal" class="modalDialog">
    </section>!-->
  <script type="text/javascript">
var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));

elems.forEach(function(html) {
  var switchery = new Switchery(html);
);
</script>

  </form>

And finally I receive them in my other PHP file:

    <?php
   //include('plantilla.php');
   require('conexion.php');
   require 'fpdf.php';
   class PDF extends FPDF
  {
    function Header()
    {
        // Logo
        $this->Image('umss.png',20,13,55);
        // Arial bold 15
        $this->SetFont('Arial','B',9);
        $this->SetX(100);
        $this->MultiCell(94,4,'Secretaría de Educación Pública',0,'R',0);
        $this->SetX(100);
        $this->MultiCell(94,4,'Subsecretaría de Educación Media Superior ', 0,'R',0);
        $this->SetX(74);
        $this->MultiCell(120,4,'Unidad de Educación Media Superior Tecnológica Industrial y de Servicios',0,'R',0);
        $this->SetX(164);
        $this->MultiCell(30,4,'Estado de Hidalgo CETIS No. 26', 0,'R',0);
        // Movernos a la derecha
        $this->Ln(5);
    }
   /*$idr= $_POST['CURP'];
   $strConsulta = "SELECT * FROM inscripciones where CURP = '$idr'";
   $alumno = mysql_query($strConsulta);
   $fila = mysql_fetch_array($alumno);*/
   //$abr=$_POST["FOLIO"];

   function Footer()
    {
        // Posición: a 1,5 cm del final
        $this->SetY(-15);
        // Arial italic 8
        $this->SetFont('Arial','I',8);
        // Número de página
        $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
    }
  }

   $abr=($_POST['FOLIO']);
    $fl=$abr;
    $nom=$_POST['NOMBRE'];
    $pdf=new PDF('P','mm','A4');

   $pdf->AddPage();

   $pdf->Ln(5);
   $pdf->SetX(50);
   $pdf->SetFont('Arial', 'BU', 12);
   $pdf->Cell(100, 10,'PASE DE INGRESO AL EXAMEN', 0,0,'C');

   // Título
   $pdf->SetX(170);
   $pdf->Cell(23,27,'Foto',1,0,'C');

   // Salto de línea
   $pdf->Ln(20);

   $pdf->SetFont('Arial','B',10);
   $pdf->SetX(10);
   $pdf->MultiCell(100,10,utf8_decode('NÚMERO DE FOLIO: '.$fl),0,'C',0);
   $pdf->SetX(20);
   $pdf->MultiCell(100,10,utf8_decode('Nombre: '.$nom),0,'C',0);
   $pdf->Output();
?>

The problem is that you are not receiving what the input saves, so I would like to know how to recover the value of my variables that I defined in the other PHP file, I hope you can help me, gracefully. :)

    
asked by Oscar Reyes 21.09.2018 в 20:48
source

2 answers

0

Replaces disabled="false" with readonly="readonly"

Items that have the readonly attribute can not be modified, but their content is sent when the user submits the form.

Elements with the attribute disabled not only can not be modified, but are not sent together with the other fields in the form .

Another of its main differences is that the readonly elements can get the focus of the browser (by pressing Tab several times, you could get to select it) while the disabled elements can not get the focus.

Source

    
answered by 23.09.2018 / 16:03
source
1

You could try receiving them with $ _ REQUEST :

...
$abr=$_REQUEST['FOLIO']; // Aunque, sin los parentesis supongo
    $fl=$abr;
    $nom=$_REQUEST['NOMBRE'];
    $pdf=new PDF('P','mm','A4');
...
    
answered by 21.09.2018 в 21:27