程序題找錯誤
/*
用戶登陸程序
找出程序中的錯誤
*/
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-->
用戶登陸程序
找出程序中的錯誤
*/
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-->
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.