EDIT: There are invisible spaces after the PHP tag. I removed them, and it's now working.
So I have this website project that was built for 4 weeks. THE LOGIN FORM HERE IS WORKING.
This is the code for the login.php
<?php
session_start(); // Starting Session
$error='';
if (isset($_POST['ComeIn'])) { //NAME OF THE BUTTON CLIKED
if (empty($_POST['email']) || empty($_POST['pwd'])) { //IF EMPTY
$error = "Username or Password is invalid";
}
else
{
$username=$_POST['email'];
$password=$_POST['pwd'];
include ('connection.php');
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$query = mysql_query("SELECT * from user_account where Password='$password' AND Email='$username'", $connection);
$row1= mysql_fetch_array($query);
$rows = mysql_num_rows($query);
if ($rows == 1) { //IF OK
if ($row1['AccType'] == "Teacher")
{
$_SESSION['login_user']=$username; // Initializing Session
header("location: teachers/teacherprofile.php"); // Redirecting To Other Page
}
else if ($row1['AccType'] == "Student")
{
$_SESSION['login_user']=$username; // Initializing Session
header("location: students/studentprofile.php"); // Redirecting To Other Page
}
else
{
echo ("<script language = 'Javascript'>
window.alert('Incorrect Input!')
window.location.href='index.php'
</script>");
}
} else
{
echo ("<script language = 'Javascript'>
window.alert('Incorrect Input!')
window.location.href='index.php'
</script>");
}
}
mysql_close($connection);
}
?>
But this admin login form is not working and it has almost the same code. It's not going anywhere. It's just going to login2.php and none of the PHP functions are working. Below is the login2.php:
<?php
session_start(); // Starting Session
$error='';
include ('connection.php');
if (isset($_POST['login'])) { //NAME OF THE BUTTON CLIKED
if (empty($_POST['aemail']) || empty($_POST['apwd'])) { //IF EMPTY
$error = "Username or Password is invalid";
}
else //TEXTFIELDS NOT EMPTY
{
$username=$_POST['aemail'];
$password=$_POST['apwd'];
include ('connection.php');
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$query = mysql_query("SELECT * from service_account where CS_Password='$password' AND CS_Email='$username'", $connection);
$row1= mysql_fetch_array($query);
$rows = mysql_num_rows($query);
if ($rows == 1) { //IF OK
if ($row1['SA_Type'] == "Admin")
{
$_SESSION['login_user']=$username; // Initializing Session
header("location: admin/admin_dashboard.php"); // Redirecting To Other Page
}
else if ($row1['SA_Type'] == "Customer Service")
{
$_SESSION['login_user']=$username; // Initializing Session
header("location: cservice/cs_inquiry.php"); // Redirecting To Other Page
}
else
{
$error = "Username or Password is invalid";
header("location: login_csa.php");
}
} else
{
$error = "Username or Password is invalid";
header("location: login_csa.php");
}
mysql_close($connection);
}
}
?>
Im debugging this for two days now. THe weird part is, When I tried to use the system in localhost, it's perfectly working. When I put it in iPage.com, that happens. Any suggestions?