程序题找错误

来源:互联网 发布:集中采购软件 编辑:程序博客网 时间:2024/04/29 20:42
<?
/*
用户登陆程序
找出程序中的错误
*/
if($_post){
$host="localhost";//
$port=3306;
$usr="pphoo";
$pasword="090909";
$db="xiangmu";
$table="xm_note"
$link=mysql_connect($host,$usr,$pasword)  ;
if(!$link) exit("数据库连接失败");
if(!mysql_select_db($db,$link)) exit("数据库选择失败");
@mysql_query("SET NAMES gb2312");
 $username=($_post['username']==ff)?"fffffff":$_post['username']
  $password=md5 $_post['password']
    $sql="select  count(1)  as num from $table  where `username`= $username and `password`=$password";
 $a=mysql_fetch_array($sql);
 if($a["num"]!=0){
 echo "<script>alert("登陆失败")</script>"
 }else{
 header("locaton:index.php");
 }
}
?>
<!--form表单start-->
<script>
function check(){
if(document.s1.username.length==0){
alert("请输入字符");
return false;
}else{
 return ture;
}
}
</script>
<form action="" method="POST" onsubmit="check()" name="s1">
 <p>姓名:<input type="text" name="username">
 <p>密码:<input type="text" name="password">
 <p>密码:<input type="submit" name="submit" value="提交">
</form><!--end-->
原创粉丝点击