newphpcoder;10962748 wrote:your right that code was not work,i don't know why and i don't know what should be the coe for that..when i input wrong username and department and i press the submit button no error appear and also the echo "Incorrect Username and Department" was not appear.
The text "Incorrect Username and Department" surely won't appear as on what you want, because the page is redirected to index.php and the echo you placed right after the header() well should I say left on that page.
If I were to print the string "Incorrect Username and Department", I'll have this else :
else {
$_SESSION['dummy'] = 1;
header('location:index.php');
}
Then assuming this is my index.php
<?php
session_start();
if($_SESSION['dummy'] == 1) {
$text = "Incorrect Username and Department";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php echo $text; ?>
</html>