Here is my code. It is perfectly working on Local but not server. Need any library to work on server.
<?php
//include "../dbconnect/cnn_mysql.php";
//mysql_query("insert into admin (loginid, pass) values ('superuser', '".md5('mypassword123')."')");
if($_POST)
{
include "../dbconnect/cnn_mysql.php";
//$userid=mysql_real_escape_string($_POST["userid"]);
//$pass=mysql_real_escape_string($_POST["pass"]);
$userid=secure_form_data($_POST["userid"]);
$pass=md5(secure_form_data($_POST["pass"]));
$result=mysql_query("select * from admin where loginid='$userid'");
if($result && mysql_num_rows($result)>0)
{
$row=mysql_fetch_array($result);
$auserid = $row["loginid"];
$apassword = $row["pass"];
if($auserid == $userid && $apassword == $pass)
{
session_start();
$_SESSION["adminid"]=$userid;
header("location: main.php");
exit();
}
else
{
$errors[]="1.1";
}
}
else
{
$errors[]="1.1";
}
/*$userid=secure_form_data($_POST["userid"]);
$pass=secure_form_data($_POST["pass"]);
$result=mysql_query("select * from admin where loginid='$userid' and pass='$pass'");
if($result && mysql_num_rows($result)>0)
{
session_start();
$_SESSION["adminid"]=$userid;
header("location: main.php");
exit();
}
else
{
$errors[]="1.1";
}*/
}
?>
<!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>KPO Jobs: Admin</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<script language="javascript">
function checkform(theform)
{
var flds="";
if(theform.userid.value=="")
flds += " *Login id\n";
if(theform.pass.value=="")
flds += " *Password\n";
if(flds!="")
{
alert("The following fields can't be left blank\n"+flds);
return false;
}
return true;
}
</script>
</head>
<body>
<div id="body_container">
<div id="head">
<img src="images/logo.jpg" class="logo" alt="KPO Jobs">
</div><!--head-->
<div id="main_content" class="main_content centeralgin">
<div id="for_height"></div>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" class='th_form width1' onsubmit="return checkform(this);" >
<fieldset>
<legend>Login</legend>
<?php
include "module_error.php";
?>
<div class="form_row">
<label for="userid"><span>*</span>Login id:</label>
<input type="text" id="userid" name="userid" size="30">
</div>
<div class="form_row">
<label for="pass"><span>*</span>Password:</label>
<input type="password" id="pass" name="pass" size="30">
</div>
<div class="form_row">
<label > </label>
<input type="submit" id="login_bt" name="login_bt" value="Login">
</div>
<div class="formtip">Fields marked with <span>*</span> are compulsorry to fill.</div>
</fieldset>
</form>
<div class="clear"></div>
</div><!--main_content-->
<?php include "module_footer.php";?>
</div><!--body_container-->
</body>
</html>