第1个回答 推荐于2017-12-15
很简单 密码为123456 你可以在login.php里面改
index.html 将以下代码放入 <body></body>里面就可以
<form method="post" action="login.php">
密码: <input type="password" name="password"/><br>
<input type="submit" name="submit" value="登陆">
</form>
login.php 完整的login.php内容
<?php
$password = isset($_POST['password']) ? $_POST['password'] : '';
if($password == '123456'){
echo "<script>alert('登陆成功。');location.href='in.html';</script>";
//不需要提示 则把 alert('登陆成功。'); 删除掉
}else{
echo "<script>alert('密码错误 登陆失败。。');location.href='error.html';</script>";
//不需要提示 则去掉 同上
}
?>
OK 了 简单吧。本回答被提问者采纳
第2个回答 2010-07-15
checkImg.php
<?php
//生成验证码图片
session_start();
Header("Content-type: image/png");
srand((double)microtime()*1000000);
$im = imagecreate(45,18);//设置图片的宽与高
$black = ImageColorAllocate($im, 58,75,242);//设置背景颜色
$white = ImageColorAllocate($im, 255,255,255);//设置文字颜色
$gray = ImageColorAllocate($im, 200,200,200);//干扰颜色
imagefill($im,45,18,$gray);
while(($chk_num=rand()%10000)<1000);
$_SESSION["chk_num"] = $chk_num;
//将四位整数验证码绘入图片
imagestring($im, 5, 5, 1,$chk_num , $white);//5, 5, 1分别表示为字体大小,左边距,上边距
for($i=0;$i<100;$i++) //加入干扰象素
{
imagesetpixel($im, rand()%70 , rand()%30 , $gray);
}
ImagePNG($im);
ImageDestroy($im);
?>
html页面增加验证码图片
<img id="img1" src="checkImg.php" alt="看不清?点击更换" onclick="this.src=this.src+'?'" style="margin-top: 5px;" />
前提还需要你打开GD扩展
打开php.ini文件
将extension=php_gd2.dll前面的;去掉
第3个回答 2010-07-15
login.php
<?
session_save_path("./");
session_start();
$pwd=$_POST['pwd'];
$user=$_POST['user'];
$define_user="用户名";//设定的用户名
$define_pwd="密码";//设定的密码
if($login_submit){
if($user!=$define_user)$str="您的用户名错误!";
else{
if($pwd!=$define_pwd) $str="您的密码错误!";
else{
session_register("ses_user");
$ses_user="用户名";
header("location:index.php");
}
}
}
?>
<html>
<head><title>进入验证</title>
</head>
<style>
table{font-size:9pt;}
</style>
<body><br>
<form name="form1" method="post" action=<?echo $PHP_SELF ?> >
<table border="0" cellpadding="3" cellspacing="1" align="center" width="300" bgcolor="#3399CC">
<tr height="25" bgcolor="#E7E7E7"><td colspan="2"><b>XXXXXX--</b>进入验证</td></tr>
<tr height="25" bgcolor="#e7f7f7" ><td align="right">用户:</td><td><input type="text" name="user"></td></tr>
<tr height="25" bgcolor="#e7f7f7" ><td align="right">密码:</td><td><input type="text" name="pwd"></td></tr>
<tr height="25" bgcolor="#e7f7f7" ><td></td><td><input type="submit" name="login_submit" value="提交"><?echo "<font color=red>".$str."</font>";?></td></tr>
</table>
</form>
index.php
<?
session_save_path("./");
session_start();
if(!session_is_registered("ses_user")) header("location:login.php");//这里也可以判断答案是否正确来处理
//下面是你要加的内容
///
///
?>
验证通过,进入了主页了
第4个回答 2010-07-15
index.html页
<form method="post" action="login.php">
<input type="text" name="user" value=""/><br>
<input type="text" name="password" value=""/>
</form>
login.php页
$user = isset ($_POST['user']) ? $_POST['user']:"";
$password = isset ($_POST['password ']) ? $_POST['password ']:"";
if ($user == "admin" and $password == "123"){
header("Location: in.html ");
}
else{
header("Location: error.html ");
}
index.html 放在<body> </body>里面
login.php 放到<?php ?>里面