David Passmore
David Passmore

Reputation: 6099

$_POST not passing any variables

I am constructing a advanced login system for one of my new projects, however the problem i am having is in the simplest part. the posted form data.

The data from which is not being transferred between the below pages. I have been going over this for an hour now and I cannot find a problem.

Your guys' help would be appreciated, Thanks.

Code and Notes:

login.php:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Live Home :: Client Login</title>

        <link rel="stylesheet" href="css/core.core.css" type="text/css" />
        <script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>
        <script src="js/common.js" type="text/javascript"></script>
        <script src="bundles/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    </head>

    <body>

        <header>
          <div class="bar"></div>
            <div class="btm"></div>
        </header>


        <section id="login">
          <div class="drop">
            <div class="top">
                <h2>Live Home</h2>
                <hr class="sec-sep" style="width:100px;" />
            </div>
            <section id="FOH">
                <div class="inner">
                    <form class="form-horizontal" method="post" id="logon-form" action="auth/logon.php">
                        <div class="control-group">
                            <label class="control-label" for="inputEmail">Username / Email : </label>
                            <div class="controls">
                                <input type="text" id="inputEmail" placeholder="Username / Email" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="inputPassword">Password : </label>
                            <div class="controls">
                                <input type="password" id="inputPassword" placeholder="Password" />
                            </div>
                        </div>
                        <div class="control-group">
                            <a id="login-btn" class="btn btn-primary btn-mid-login">Sign in</a>
                        </div>
                    </form>
                </div>
                <div class="login-loader"></div>
            </section>
          </div>
        </section>

    <script type="text/javascript">

    $(window).bind('load resize', setPos);

    function setPos(){
        $('#login').css({
            'margin-top':   ($(window).height() / 2) - ($('#login').height() / 2) - (($(window).height() / 100) * 10)
        });
    }

    $(document).ready( function() {

        $('#login-btn').click( function() {
            $('.inner').stop(true, true).fadeOut({ duration: 700, queue: false }).slideUp(700); 
            $('.login-loader').delay(700).fadeIn(300); 
            setTimeout(function() {
                $('#logon-form').submit();  
            },2800);
        });

    });

    </script>

    </body>
</html> 

auth/logon.php:

<?php
    /**=====================================================================

    logon.php

    This file logs users into the main system.

    =======================================================================*/

    class access {

        function authenticate () {

            $user_request = $_POST;

            if(isset($user_request)){

                $username = $user_request['inputEmail'];

                $password = $user_request['inputPassword'];

                var_dump($_POST);

            }else{

                header("Location: ../../login.php");

            }

        }

    }

    $access = new access();
    $access -> authenticate();
?>

To see the pages in action click here.

Upvotes: 0

Views: 187

Answers (3)

Halcyon
Halcyon

Reputation: 57709

I would change

if(isset($user_request)){

to

if(isset($user_request['inputEmail'], $user_request['inputPassword'])){

And also put an exit statement in the if-body to be sure the code ends where you expect it to. That header Location may happen so fast you don't see it.

Upvotes: 0

user1343875
user1343875

Reputation:

Your input fields have no 'name' attributes.

Upvotes: 2

Daniel Kurz
Daniel Kurz

Reputation: 816

The reason is that PHP uses the name attribute. if your input is name = 'test' that in PHP it would be $_POST['test']

Upvotes: 3

Related Questions