Patrik Horváth
Patrik Horváth

Reputation: 177

PHP $_POST no work

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.

Upvotes: 1

Views: 86

Answers (2)

Twinfriends
Twinfriends

Reputation: 1987

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.

Upvotes: 1

Devendra Singh
Devendra Singh

Reputation: 99

try

<?php print_r($_POST); ?>

and setup form action in your form tag

Upvotes: 0

Related Questions