0

I am trying to print out the values of a login box in php but the values always appear empty. If i add an explicit value to the echo it works. Please can someone advise me on what I might be doing incorrectly. Thanks

<form name="login-form" class="login-form" action="index.php" method="post">

    <!--HEADER-->
    <div class="header">
    <!--TITLE--><h1>Client Portal Login</h1><!--END TITLE-->
    <!--DESCRIPTION--><span>Please login to your client portal</span><!--END DESCRIPTION-->
    </div>
    <!--END HEADER-->

    <!--CONTENT-->
    <div class="content">
    <!--USERNAME--><input name="username" type="text" class="input username" value="Username" onfocus="this.value=''" /><!--END USERNAME-->
    <!--PASSWORD--><input name="password" type="password" class="input password" value="Password" onfocus="this.value=''" /><!--END PASSWORD-->
    </div>
    <!--END CONTENT-->

    <!--FOOTER-->
    <div class="footer">
    <!--LOGIN BUTTON--><input type="submit" name="submit" value="Login" class="button" /><!--END LOGIN BUTTON-->
    <!--REGISTER BUTTON--><input type="submit" name="submit" value="Register" class="register" /><!--END REGISTER BUTTON-->
    </div>
    <!--END FOOTER-->

</form>

<?php
if(isset($_POST['submit'])){
    $username=$POST["username"];
    $password=$POST["password"];

echo $username . " " . $password;
}

?>
Biscuit128
  • 5,218
  • 22
  • 89
  • 149

1 Answers1

0

You've made a typo. You need $_POST, not $POST

http://www.php.net//manual/en/reserved.variables.post.php

Edit: Also, please consider cleansing your $_POST data:

Do htmlspecialchars and mysql_real_escape_string keep my PHP code safe from injection?

Community
  • 1
  • 1
rroberts
  • 74
  • 3
  • Likely before I added the edit. I posted while I was still looking for an appropriate link for the cleansing part of my comment, so it didn't add a ton of value yet. *shrugs* – rroberts Jun 10 '14 at 20:04