1

tried method get and $_GET it works perfect but when i try method post and $_POST or $_REQUEST nothing happens =\ any help ? thanks

PHP and FORM is in SAME PAGE

HTML :

<form method="post">
    <div class="form-group">
        <label for="user">Meno:</label>
        <input type="text" id="user" name="user" class="form-control" placeholder="meno admina" required>
    </div>
    <div class="form-group">
        <label for="psw">Heslo:</label>
        <input type="password" id="psw" name="password" class="form-control" placeholder="heslo admina" required>
    </div>
    <div class="form-group">
        <input type="submit" class="btn btn-success" name="submit" v>
    </div>
</form>

PHP :

<?php
if (isset($_POST["submit"])) {
    $user = htmlspecialchars(strip_tags($_POST['user']));   
    echo $user;
}
?>

Tried also just echo $_POST['user']; but nothing.

Prerak Sola
  • 9,517
  • 7
  • 36
  • 67
Patrik Horváth
  • 177
  • 1
  • 1
  • 15

2 Answers2

1

Edit:

For all who have the same problem, its all about this line:

<form method="post"> - post have to be written in uppercase, like:

<form method="POST"> - This solved the problem.

Twinfriends
  • 1,972
  • 1
  • 14
  • 34
0

try

<?php print_r($_POST); ?>

and setup form action in your form tag

Devendra Singh
  • 99
  • 1
  • 2
  • 13