I'm creating the login page for my admin area to my CMS I am working on. I am using the "if" statement to echo instructions if the form input fields are blank. However, the echo will not work inside the "if" statement. I tried moving the echo outside of the "if" statement and it works fine and echos like it should except when inside the if statement.
admin-login.php
PHP
HTMLPHP Code:<?php include_once ('include/scripts/login.php'); ?>
login.phpHTML Code:<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" href="style/css/style.css"></link> <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script> </head> <body> <!--START: Log In Wrapper--> <div id="login-wrapper"> <!--START: Error Display--> <div id="login-errors"> </div> <!--END: Error Display--> <!--START: Log In Form--> <div id="login-form"> <h2>Admin Login Panel</h2><!--Login Header--> <!--START: Login Form--> <form method="post" action="admin-login.php"> <!-- START: Form Element USERNAME--> <div class="form-element"> <label for="Username" class="admin-login-label">Username</label><!--Username Label--> <input type="text" name="username" placeholder="Enter Username" id="admin-username"/><!--Username Input--> </div> <!-- END: Form Element USERNAME--> <!-- START: Form Element PASSWORD--> <div class="form-element"> <label for="Password" class="admin-login-label">Password</label><!--Password Label--> <input type="text" name="password" placeholder="Enter Passowrd" id="admin-password"/><!--Password Input--> </div> <!-- END: Form Element PASSWORD--> <!-- START: Form Element SUBMIT--> <div class="form-element"> <label></label><!--Leave Blank--> <input type="Submit" name="logintoadmincenter" value="Login" id="admin-login-button" /><!--Username Input--> </div> <!-- END: Form Element SUBMIT--> </form> <!--END: Login Form--> </div> <!--END: Log In Form--> </div> <!--END: Log In Wrapper--> </body> </html>
I receive no errors. It just doesn't echo, even if written as:PHP Code:<?php
if(isset($_post['logintoadmincenter'])) {
include_once '.:include/connection.php';
$username = $_post['username'];
$password = $_post['password'];
if (empty($username) || empty($password)) {
echo ("Please fill in the required fields");
}
}
?>
ORPHP Code:echo ('Please fill in the required fields');
ORPHP Code:echo "Please fill in the required fields";
PHP Code:echo 'Please fill in the required fields';



Reply With Quote



Bookmarks