Inicio » Blog » PHP

19 noviembre, 2020

Enviar y Recibir variables en PHP

Para enviar y recibir una variable usando formularios en PHP y HTML, es necesario usar métodos post o get y almacenarlos en variables PHP

Suscríbete a nuestro canal en Youtube

Suscríbirse

Para enviar y recibir una variable usando formularios en PHP y HTML, es necesario usar métodos post o get y almacenarlos en variables PHP.

Envia y Recibe variables en PHP entre dos páginas

Página que envia un request (parámetros) en PHP

index.php

<form action="recibe.php" method="post">
    <input type="text" name="txtmensaje" placeholder="Ingrese mensaje" required > <br>
    <input type="text" name="txtnombre" placeholder="Ingrese nombre" required > <br>
    <input type="submit" name="btnenviar" value="ENVIAR MENSAJE">
</form>

Página destino que recibe los parámetros y los muestra

recibe.php

<?php
if(isset($_POST['btnenviar'])){
    $m = $_POST['txtmensaje'];
    $n = $_POST['txtnombre'];
}
?>
<form action="recibe.php" method="get">
    <input type="text" name="txtmensaje2" value="<?php echo $m . " ". $n ?>">
</form>

Leido 9930 veces

Compartir link del tutorial con tus amigos


Aprende más sobre PHP

Cursos de programación

Codea Codea App

México, Colombia, España, Venezuela, Argentina, Bolivia, Perú

© Todos los derechos reservados Codea App | ...de frente al código!!! | 2020 - 2023