-1

index.php

<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>
<div style="margin: 123px 0 0 310px; position: absolute; z-index: 3;">
<form action="login_portal.php" method="POST">
<br>
<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>
</div></div></div>
<!--<input type="submit" class="login" name="submit" value=""></input>-->
</div>
<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>
</form>

    <!-- 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>
            </div>
            <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>
                    </span>
                    <h4 class="service-heading">Article</h4>

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

        include('includes/koneksi.php');

        $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?

login_portal.php

<?php

include('administrator2/admin/includes/koneksi.php');

$error = "";

echo "test";

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

echo "enter";
/* the files */

// username and password sent from form
$username=$_POST['username'];
$password=$_POST['password'];

// 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);
$result=mysql_query($sql);

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

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

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

echo $sql4;
echo $result4;

// Mysql_num_row is counting table row
$sadmin_count=mysql_num_rows($result);
$admin_count=mysql_num_rows($result2);
$student_count=mysql_num_rows($result3);
$teacher_count=mysql_num_rows($result4);

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_register("username");
//session_register("password");

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

header("location:admin/template/");
}
elseif ($admin_count>=1){

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

header("location:administrator/");

}
elseif ($student_count>=1){

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

header("location:administrator2/student/admin.php");

}
elseif ($teacher_count==1){

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

header("location:administrator2/teacher/admin.php");

//header("location:header.php");
}
else {

?>
<!-- alert add -->

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

<!-- end -->
<?php

$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.

2
Contributors
1
Reply
29
Views
2 Years
Discussion Span
Last Post by linus72982
0

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'

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.