<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
$con = mysql_connect("localhost","root","javabeanc");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("scmanager", $con);
if($_POST["Type"]=='CA') //Double equals needed here
{
$type="College Admin";
}
if($_POST["Type"]=='stud') //Double equals needed here
{
$type="Student";
}
//Added mysql_real_escape_string() the following line to stop SQL injection
$query="SELECT * FROM scmanager.user_login_details where userID= '".mysql_real_escape_string($_POST["userid"])."' AND password='".mysql_real_escape_string($_POST["psw"])."' and role='".$type."'";
$result=mysql_query($query) or die('error');
$numrows = mysql_num_rows($result);
if(!$numrows)
{
if($_POST["Type"]=='CA')
{
echo "<center>";
echo "<div class='main'>";
echo "<div class='box'>";
echo "Congrates! You got Loged In";
echo "<br><br>";
echo "<form action='ca/CAdminHome.php' method='post' name='myform'>";
echo "<input type='hidden' name='userID2' value='".$_POST["userid"]."'>";
echo "<input type='hidden' name='type2' value='".$_POST["Type"]."'>";
echo "<div class='spacer'><a href='#' onClick='document.myform.submit();' class='green'>Enter</a></div>";
echo "</form>";
echo "</div>";
echo "</div>";
echo "</div>";
echo"</center>";
echo "</body>";
}
elseif($_POST["Type"]=='stud')
{
echo "<center>";
echo "<div class='main'>";
echo "<div class='box'>";
echo "Congrates! You got Loged In";
echo "<br><br>";
echo "<form action='Student/CAdminHome.php' method='post' name='myform1'>";
echo "<input type='hidden' name='userID2' value='".$_POST["userid"]."'>";
echo "<input type='hidden' name='type2' value='".$_POST["Type"]."'>";
echo "<div class='spacer'><a href='#' onClick='document.myform1.submit();' class='green'>Enter</a></div>";
echo "</form>";
echo "</div>";
echo "</div>";
echo "</div>";
echo"</center>";
echo "</body>";
}
else
{
Header("Location: http://127.0.0.1:8080/scmanager/relogin.php");
exit;
}
}
mysql_close($con);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Welcome to ScManager Ver 1.0 | Developed by iTMarkerZ Technologies</title>
<style type="text/css">
body{ font-family:"Lucida Sans Unicode", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
color:#000000;
}
a{color:#0033CC;}
h1, h2, p, form{
border:0px;
margin:0px;
padding:0px;
}
input{ font-family:"Lucida Sans Unicode", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
}
h2{ color:#666666;
margin-bottom:20px;
font-size:16px;
}
div.main{
margin:30px auto;
width:340px;
}
div.box{
border:solid 1px #c6cfe1;
background:#dfe4ee;
padding:10px;
color:#333333;
margin-bottom:20px;
}
div.box h1 {
font-size:14px;
color:#000000;
padding-bottom:4px;
}
div.box p{padding-bottom:14px;}
div.box input .input-text{
border:1px solid #3b6e22;
color:#666666;
width:180px;
}
div.box label{
display:block;
margin-bottom:10px;
color:#555555;
}
div.box label span{
display:block;
float:left;
padding-right:6px;
width:70px;
text-align:right;
font-weight:bold;
}
.spacer{margin-left:80px;
margin-bottom:10px;
font-size:11px;
color:#555555;
}
.green{
background:url(img/green.gif);
padding:0px 6px;
border:1px solid #3b6e22;
height:24px;
line-height:24px;
color:#FFFFFF;
font-size:12px;
margin-right:10px;
display:inline-block;
text-decoration:none;
}
<body>