Call the value of a variable from one file to another

0

My situation is that I have two PHP files in which:

  • Archivo1.php (form)
  • Archivo2.php generates a consecutive code.

How can I get my generated code in archivo2.php and send it or request it to my archivo1.php (form) in which I intend to store it in a input text ?

I add my content so you can see what I need to do

My main form generates an application.

my add submit request button executes the insert from AJAX. Or there will be a way to show my result in the input, just as the page with the folio value is polled.

Once pressed my button inserts the data to my database and in turn generates my consecutive folio.

in the image in the comment where it says here the code is generated, that value of the variable is the one that I require I want it in an input text in my form.

The input text is the one under my add request button and in front of the download type, this section appears once the record is added.

I hope you have given me to understand

    
asked by Ever 28.06.2017 в 23:50
source

1 answer

0

What you can do is send the data through the url, although this is not safe if you send sensitive data such as passwords:

In Archivo1.php you send the data:

In Archivo2.php recives the data of a form and do what you have to do, to send the data in a Archivo1.php you have to do is from Archivo2.php rule with example parameters

//Archivo2.php
<?php
    //hacer algo con los datos
    //devolver datos a Archivo1.php
    header("location: informacion=" + $informacion +"); //informacion lleva los datos que quieres devolver, puedes mandar varios parametros.
?>

Now in Archivo1.php

$valor = isset($_GET['informacion']) ? $_GET['informacion'] : ''; //si la variable get informacion existe tomas esa informacion y meterla a $valor si no dejarle un string vacio
<input type="text" name="informacion" id="informacion" value = "<?=$valor?>"> <!--<?=$valor?> es una manera corta de escribir <?php echo $valor?>-->
    
answered by 29.06.2017 в 03:39