Problem: when validation in username and password in php
I got error in username during validation by this code. Anything this code, Please fix it? I am newbie for php.
<?php
session_start();
include('functions.php');
if($_SERVER['REQUEST_METHOD']=="POST"){
$qer="select * from admin where username='".$_POST['username']."' and password='".$_POST['password']."'";
$res=mysql_query(qer);
$num=mysql_num_rows($res);
if($num==0)
{
$msg=1;
}
else if($num==1)
{
session_unregister("user_name");
session_register("user_name");
$_SESSION["user_name"]=_POST["username"];
session_unregister("adminid");
session_register("adminid");
$_SESSION['adminid']=getdata("admin","id","username='"$_POST['username']."' and password='"$_POST['password']."'");
echo'<script language="ja开发者_如何学编程vascript">window.location.href="welcome.php";</script>';
}
} ?>
You should always put the error along with your question and code.
$res=mysql_query(qer);
$num=mysql_num_rows($res);
if($num==0)
Should be
$res=mysql_query($qer);
$num=mysql_num_rows($res);
if($num==0)
You forgot a $
精彩评论