0

Is it possible to create a form with PHP and process this form with the same script it was created by.

I tried this:

    <!DOCTYPE html>
<html>

<?php

if(isset($_POST['GO'])) {

echo "Hola Mundo";
}
?>

<body>
<form  action="procesarFormula.php" method="post">


     <b>Nombre</b> <input type="text" name="nombre"><br/><br/>
    <input  type="submit" value="GO"> 

 </form>
</body>
</html>

but when I click the submit button I get the Object not found error. Note the script is saved in a file called procesarFormula.php

Any help please ?

shadow
  • 43
  • 5

2 Answers2

0

Change

<input  type="submit" value="GO"> 

To

<input  type="submit" name="GO"> 

Otherwise, $_POST["GO"] will never be set

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
Necky
  • 70
  • 8
0

You should include a 'name' attribute for that submit input. The reason is your POST global variable is an array that holds all the key{name} value{value} pair for all your posted inputs. So in your code, you're calling the key, but you only have the value set.

niyi
  • 319
  • 2
  • 3