Pedro Martins Novaes
Pedro Martins Novaes

Reputation: 27

simple POST method not working

I've created an account just so I could ask this question: Why is the post method not working on these simples files?

Code on file 1:

<form method="POST" action="caralho.php">
        <input type="text" id="titulo_cardapio" />
        <input type="submit" />
</form>

file 2, "caralho.php":

<?php
$crlh = $_POST['titulo_cardapio'];
echo $crlh;
?>

This simple form somehow does not post the variables, when I load "caralho.php", after clicking the submit button, this happens:

Notice: Undefined index: titulo_cardapio in C:\xampp\htdocs\cardapio\caralho.php on line 2

HOW is this happening? This is driving me insane

Upvotes: 0

Views: 3023

Answers (1)

Ismail RBOUH
Ismail RBOUH

Reputation: 10450

Your input needs the name attribute:

<input type="text" id="titulo_cardapio" name="titulo_cardapio" />

I hope this will help you.

Upvotes: 5

Related Questions