Hi all, I am working on the following code and I am having a problem with defined variables. On the output on the Submitted and Username Inputs as being undefined. I have added $username = (isset($_POST['Username'])) ? $_POST['Username'] : ""; at the start of the function but not suppressed.
Thanks for your help
David
index.php
<?php
session_start();
ob_start();
include_once ("includes/settings.php");
include("includes/functions/functions.php");
//include_once ("includes/optional.php");
var_dump($_POST);
$Errors = "";
$_SESSION['LoggedIn'] = false;
$_SESSION['UserID'] = "";
$_SESSION['UserAdmin'] = false;
if ($_POST['Submitted'] == "true") {
// process submitted data
$userSQL = $Database->Execute("SELECT UserID, UserFullname, UserEmail, UserLastPassword FROM Users WHERE UserName = '" . mysql_real_escape_string($Text->ValidSQLString($_POST['Username'])) . "' AND UserPassword = '" . md5($_POST['Password']) . "' AND UserActive = 1 AND UserListingOnly = 0 AND UserID NOT IN (61)");
$UserCount = $Database->RecordCount($userSQL);
if ($UserCount == 1) {
// user found
$rowUser = $Database->Records($userSQL);
}//end if
}//end if
LoginForm();
?>
Login function
<?PHP
function LoginForm(){
$username = (isset($_POST['Username'])) ? $_POST['Username'] : "";
$password = (isset($_POST['Password'])) ? $_POST['Password'] : "";
?>
<form action="<?= $Settings['WS-HTTPpath']; ?>" autocomplete="off" id="Login" method="post" name="Login">
<input id="Submitted" name="Submitted" type="hidden" value="true" />
<label class="label-rounded" for="Username">Username</label>
<input class="input-text-rounded" id="Username" name="Username" type="text" value="<?= $_GET['Username']; ?>" /><br />
<label class="label-rounded" for="Password">Password</label>
<input class="input-text-rounded" id="Password" name="Password" type="password" />
<div class="centre mbottom">
<input class="button input-button-rounded shadow-small" id="LoginButton" name="LoginButton" type="submit" value="Login" />
</div>
</form>
<?php } ?>