-1

Well this is strange but my form is not passing POST data.

Here is the form

<form method="POST" action="process/processor.php">
<input name="name3" type="text">
<input type="submit" name="submit">
</form>

Here is the PHP

<?php    
if(isset($_POST['submit']) AND $_SERVER['REQUEST_METHOD'] == "POST"){   

$name = $_POST['name3'];

echo $name;

}
else{
    echo 'lol';
}

?>

Here is where it gets surprising

var_dump($_POST) gives array(0) { } on the other hand, var_dump($_GET) gives rray(2) { ["name3"]=> string(6) "fghjmk" ["submit"]=> string(6) "Submit" }

It looks like i'm getting data with GETand no data with POST. This is quite strange to me. Any suggestions?

And nothing is echoed out for variable $name

Neville
  • 484
  • 4
  • 10
  • Use === equals. if(isset($_POST['submit']) AND $_SERVER['REQUEST_METHOD'] === "POST"){ – Ahad Jan 07 '17 at 18:08
  • This doesn't solve the problem – Neville Jan 07 '17 at 18:17
  • take a look at this http://stackoverflow.com/questions/10943060/isset-postsubmit-vs-serverrequest-method-post – Ahad Jan 07 '17 at 18:22
  • Possible duplicate of [isset($\_POST\['submit'\]) vs $\_SERVER\['REQUEST\_METHOD'\]=='POST'](http://stackoverflow.com/questions/10943060/isset-postsubmit-vs-serverrequest-method-post) – Hizqeel Jan 07 '17 at 18:32
  • @Hizqeel I tried using either but still didn't get the results I expected – Neville Jan 07 '17 at 18:35

1 Answers1

0
<form method="POST" action="process/processor.php">
<input name="name3" type="text">
<input type="submit" name="submit">
</form>

instead of <input type="submit" name="submit">, use <input type="submit" name="submit" value='submit'>

the $_POST['submit'] might be empty using <input type="submit" name="submit">. so, i think is not getting into the block code.