user1688346
user1688346

Reputation: 1970

HTML form posted but array returned is empty

I am trying to does an HTTP POST but the array returned from the post is empty which it shouldn't.

var_dump($_REQUEST);
var_dump($_POST);  -->This is empty which it should NOT.

<form action="login/" class="form-horizontal well" id="login-form" method=
"post" name="login-form">
    <div class="span4 center">
        <input class="text-field input-block-level" id="email" name="email"
        placeholder="E-mail" size="30" type="email">
    </div>

    <div class="span4 center">
        <input class="text-field input-block-level" id="password" name=
        "password" placeholder="**********" size="20" type="password">
    </div><br>
    <br>

    <div class="span4 center">
        <input class="button-primary button-large" type="submit">
    </div>
</form>

Upvotes: 0

Views: 123

Answers (3)

Amal
Amal

Reputation: 76676

The ACTION attribute tells the form where to POST the data to. if there's no such location as login/, the form will fail.

It should be:

<form class="form-horizontal well" method="post" action="yourlogincheck.php" id="login-form" name="login-form">

But it's perfectly fine to post to login/ if your file structure is as follows:

  • file.php
  • login/index.php

In all other cases, it will fail. Also, make sure to add the trailing slash. It is important.

If it's POST'd correctly, you should get something like this with var_dump:

array(2) {
  ["email"]=>
  string(11) "[email protected]"
  ["password"]=>
  string(7) "hunter2"
}
array(2) {
  ["email"]=>
  string(11) "[email protected]"
  ["password"]=>
  string(7) "hunter2"
}

Hope this helps.

Upvotes: 1

Jalpesh Patel
Jalpesh Patel

Reputation: 3188

If your login.php in same directory than please set as per below other wise please set path in action and check it

<form action="login.php" class="form-horizontal well" id="login-form" method=
"post" name="login-form">
   your html code here
</form>

I hope this helps you

Upvotes: 1

Zevi Sternlicht
Zevi Sternlicht

Reputation: 5399

You are sending the POST to the login page. Send the action to the page that checks if they exist

Upvotes: 1

Related Questions