0

I know that when creating the php, if you try to call an index that wasn't defined it will give you the notice from the tile, but I dont know how I can fix it in the way Im trying to create it. Its very basic code. The form:

        <form action="procesar.php" method="get">
            <p>Su nombre: <input type="text" name="nombre"/></p>
            <p>Su e-mail: <input type="text" name="email"/></p>
            <p><input type="submit" name="Enviar"/></p> 
        </form>

And here is the php:

<html>
    <body>
        <p>Hola <?php echo $_POST ["nombre"]; ?><br></p>
        <p>El teu e-mail es: <?php echo $_POST ["email"]; ?></p>
    </body>
</html>

I know there are some missing things in the form like the html or head and body, but Im always getting this :

https://i.stack.imgur.com/4aaEY.png

  • 1
    Do you display the html part only when the user sumbit the form ? And your form has `method="get"` and you use `$_POST`, what if you try `$_GET['nombre']` and `$_GET['email']` ? Or change for `method=post` – Mickaël Leger Dec 10 '19 at 15:44

1 Answers1

0

You are sending the form as a get request as opposed to post.

In order to access the variables as $_POST, you will need to update your method property of your form to post as below.

<form action="procesar.php" method="post">

  <p>Su nombre: <input type="text" name="nombre"/></p>
  <p>Su e-mail: <input type="text" name="email"/></p>
  <p><input type="submit" name="Enviar"/></p> 

</form>

This means that the form will send as a POST request, instead of a GET request to your action

DanLewis
  • 102
  • 1
  • 8