利用html和php 在用户登录页面 点击登录的button后,提交表单并转到用户个人信息页面(下面分别是php)

以下是html文件:
<!DOCTYPE html><html>
<head>
<title>title</title>
</head>
<body>
<form action="index.php" method="post">
用户名:<input type="username" name="username" />
<br />
密码:<input type="password" name="password" />
<br />
<input type="submit" name="submit" value="登陆" />
</form>
</body>
</html>

以下是php文件
<!DOCTYPE html><html>
<head>
<title>title</title>
<!-- 页面基本设置禁止随意更改 -->
<meta charset="utf-8">
<meta name="author" content="forework">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="msapplication-tap-highlight" content="no">
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<!-- 页面基本设置禁止随意更改 -->
<!-- 基础CSS类库可随意更改 -->
<link rel="stylesheet" type="text/css" href="css/less.css">
<link rel="stylesheet" type="text/css" href="css/basic.css">
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="css/ie8.css">
<![endif]-->
<!--[if gte IE 9]>
<link rel="stylesheet" type="text/css" href="css/ie.css">
<![endif]-->
<!-- 基础CSS类库可随意更改 -->
<!-- 基础js类库可随意更改 -->
<!-- 基础js类库可随意更改 -->
</head>
<body>
<?php
//if(isset($_POST["submit"]) && $_POST["submit"] == "登陆")
//if(isset($_POST["submit"]))
if(isset($_POST["username"]))
{
$user = $_POST["username"];
$psw = $_POST["password"];
if($user == "" || $psw == "")
{
echo "<script>alert('请输入用户名或密码!'); history.go(-1);</script>";
}
else
{
$con = mysql_connect("localhost","root","root");
if (!$con){
die('Could not connect: ' . mysql_error());
}
else{
echo '数据库连接成功';
}
//$con=mysql_connect("localhost","root","root");
mysql_select_db("doctorstation",$con);
mysql_query("set names 'utf8'");
$sql = "select doctorname,doctorpassword from doctors where doctorname = '$_POST[username]' and doctorpassword = '$_POST[password]'";
$result = mysql_query($sql,$con );
$num = mysql_num_rows($result);
if($num)
{
$row = mysql_fetch_array($result); //将数据以索引方式储存在数组中
echo $row[0];
echo $num;
}
else
{
echo "<script>alert('用户名或密码不正确!');history.go(-1);</script>";
}
}
}
else
{
echo "<script>alert('提交未成功!'); history.go(-1);</script>";
}
?>
</body>
</html>
分别是html和php文件

在php代码里,如果信息匹配成功,给一个跳转header("你个人信息地址"),很简单的。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2020-04-19
这个php页面显示找不到文件
第2个回答  2016-07-25
问题都不提。。。
第3个回答  2016-07-25
问题是什么呢

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网