<div style="margin: 120px 0 0 150px; font-size: 14px;">
<div id="banner-background2">
<div style="margin: 65px 0 0 -290px; position: absolute;">
<input type="text" class="form" name="username" value="ghi">
<input type="password" class="form" name="password" value="jkl">
<div style="margin: 123px 0 0 310px; position: absolute; z-index: 3;">
<form action="login_portal.php" method="POST">
<input type="password" class="form2" name="password" value="abc">
<div style="margin: 15px 0 0 330px; position: absolute;">
<input type="hidden" value="submit" name="submit" />
<div style="margin: -20px 0 0 -600px;"><input type="image" src="images/login.jpg" alt="submit" width="200px"></div></div>
<!--<input type="submit" class="login" name="submit" value=""></input>-->
<div style="margin: -235px 0 0 1050px;"><!--<a href="create_account.php">--><a href="#">Create an Account</a><br><!--<a href="forget_password.php">--><a href="#">Forgot Password</a></div>
<div style="margin: -20px 0 0 800px;"><input type="checkbox" name="keeplogin" value="Keep me logged in">Keep me logged in<br></div>

    <!-- Services Section -->
    <section id="services">
        <div class="container">
            <div class="row">
                <div class="col-lg-12 text-center">
                    <h2 class="section-heading">Services</h2>
                    <h3 class="section-subheading text-muted">Lorem ipsum dolor sit amet consectetur.</h3>
            <div class="row text-center">
                <div class="col-md-4">
                    <span class="fa-stack fa-4x">
                        <i class="fa fa-circle fa-stack-2x text-primary"></i>
                        <i class="fa fa-shopping-cart fa-stack-1x fa-inverse"></i>
                    <h4 class="service-heading">Article</h4>

        <li><!--<a href="#tabs-1">-->


        $result = mysql_query("SELECT * FROM `static_page` WHERE post_id='12'") or die(mysql_error());

I wonder why I cannot login after I press the login button?




$error = "";

echo "test";

if (@$_POST['submit']) { 

echo "enter";
/* the files */

// username and password sent from form

// To protect MySQL injection (more detail about MySQL injection)

$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

$encrypted_password = md5($password);

echo $username;
echo $password;

$sql = "SELECT * FROM user WHERE username='$username' and password='$encrypted_password' and access='sadmin'" or die(mysql_query);

$sql2 = "SELECT * FROM user WHERE username='$username' and password='$encrypted_password' and access='admin'" or die(mysql_query);

$sql3 = "SELECT * FROM student WHERE stu_username='$username' and stu_password='$encrypted_password'" or die(mysql_query);

$sql4 = "SELECT * FROM teacher WHERE teach_username='$username' and teach_password='$encrypted_password'" or die(mysql_query);

echo $sql4;
echo $result4;

// Mysql_num_row is counting table row

echo "admin count :".$sadmin_count;
echo "teacher count :".$teacher_count;
echo "student count :".$student_count;
// If result matched $username and $password, table row must be 1 row

if ($sadmin_count>=1){

// Register $myusername, $mypassword and redirect to file "login_success.php"

$_SESSION['username'] = $username;
$_SESSION['password'] = $password;

elseif ($admin_count>=1){

$_SESSION['username'] = $username;
$_SESSION['password'] = $password;


elseif ($student_count>=1){

$_SESSION['username'] = $username;
$_SESSION['password'] = $password;


elseif ($teacher_count==1){

$_SESSION['username'] = $username;
$_SESSION['password'] = $password;


else {

<!-- alert add -->

<div id="user_message3"></div>

<!-- end -->

$error = "Please try again.";

This suppose to work! At least processing the login_portal.php - but this is not the case. Nothing happen after I press the login button.

I just did a quick once-over, but here's what I saw:
You are checking to make sure $_POST['submit'] is equal to true to start processing. Try adding a name and value to the input:

<input type="image" src="images/login.jpg" alt="submit" width="200px" name="submitButton" value="login">

and then check for that name and value to enter the login script:

if ($_POST['submitButton'] == 'login'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.