Inicio » Blog » PHP
Enviar y Recibir variables en PHP

Enviar y Recibir variables en PHP

Enviar y Recibir Variables PHP

¿Cómo recibir una variable en un input formulario con 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

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.

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>

 

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>

Descarga código fuente 0

No hay descargable

Redactado por: , Leido 7197 veces

Más tutoriales de programación PHP

Codea App
Codea App FullStack

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

You Fb Tik Pin

© Todos los derechos reservados Codea App | Cursos de programación | 2020 - 2022