Form sending NULL to PHP?

Asked

Viewed 96 times

1

I have a FORM that should send the user ID to PHP, but PHP receives null.

HTML: (the <?=$individuo["ID"] is returning id correctly)

<form name="alterar" action="alterar.php" method="POST">
    input type="text" name="id" value=<?=$individuo["ID"]?>>
    <input type="submit" name="Editar" value="editar"> 
</form>

PHP:

 <?php 

        var_dump($_POST["ID"]);
    ?>

2 answers

0

Forgot to put the echo and uses single quotes.

Put your code like this:

<form name="alterar" action="alterar.php" method="POST">
    <input type="text" name="id" value="<?php echo $individuo['ID'] ?>">
    <input type="submit" name="Editar" value="editar"> 
</form>

0


Hello,

Even the $_POST indices are Case Sensitives, i.e., the right name would be "ID"

<form name="alterar" action="alterar.php" method="POST">
<input type="text" name="ID" value=<?=$individuo["ID"]?>>
<input type="submit" name="Editar" value="editar"> 
</form>

Or Change php this way:

<?php 

    var_dump($_POST["id"]);
?>
  • I’m impressed with, no matter how long you program, the problem will always be something silly like this. You saved my night, thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.