conn\0.ini<tr>
<td height="25" colspan="4" align="center"><span class="STYLE6">普通用户</span></td>
</tr>
<?php
$query="select * from tb_administrator ";
$result=mysql_query($query);
while($myrow=mysql_fetch_array($result)){
?>
<tr>
<td width="116" align="center"><span class="STYLE6"><?php echo $myrow[user];?></span></td>
<td width="97" align="center"><span class="STYLE6"><?php echo $myrow[pass];?></span></td>
<td height="25" colspan="2" align="center"><span class="STYLE6"><?php echo $myrow[qx];?></span></td>
</tr>
<?php }?>
conn\1.php
<tr>
<td height="25" colspan="4" align="center"><span class="STYLE6">管理员</span></td>
</tr>
<?php
if($Submit==true){
$query=mysql_query("insert into tb_administrator (user,pass,qx)values('$users','$passs','$pxs')");
if($query==true){
echo "<script>alert('普通用户创建成功!'); history.back();</script>";
}
}
$query="select * from tb_administrator ";
$result=mysql_query($query);
while($myrow=mysql_fetch_array($result)){
?>
<tr>
<td align="center"><span class="STYLE6"><?php echo $myrow[user];?></span></td>
<td align="center"><span class="STYLE6"><?php echo $myrow[pass];?></span></td>
<td height="25" colspan="2" align="center"><span class="STYLE6"><?php echo $myrow[qx];?></span></td>
</tr>
<?php }?>
<form name="form1" method="post" action="index.php">
<tr>
<td align="center"><input name="users" type="text" id="users" size="10"></td>
<td align="center"><input name="passs" type="text" id="passs" size="10">
<input name="pxs" type="hidden" id="pxs" value="0"></td>
<td height="25" colspan="2" align="center"><input name="Submit" type="submit" value="创建"></td>
</tr>
</form>
conn\2.ini
<tr>
<td height="25" colspan="4" align="center"><span class="STYLE6">超级管理员</span></td>
</tr>
<tr>
<td align="center" class="STYLE6">用户名</td>
<td align="center" class="STYLE6">密码</td>
<td width="127" height="25" align="center" class="STYLE6">权限</td>
<td width="137" align="center" class="STYLE6"> </td>
</tr>
<form name="form2" method="post" action="index_ok.php">
<tr>
<td align="center"><input name="user" type="text" id="user" size="10"></td>
<td align="center"><input name="pass" type="text" id="pass" size="10"></td>
<td height="25" align="center"><input name="qx" type="text" id="qx" size="10"> </td>
<td height="25" align="center"><span class="STYLE6">
<input type="submit" name="Submit3" value="创建">
</span></td>
</tr>
</form>
<form name="form3" method="post" action="index_ok.php">
<?php
$query="select * from tb_administrator ";
$result=mysql_query($query);
while($myrow=mysql_fetch_array($result)){
?>
<tr>
<td align="center">
<input name="user" type="text" id="user" value="<?php echo $myrow[user];?>" size="10"></td>
<td align="center">
<input name="pass" type="text" id="pass" value="<?php echo $myrow[pass];?>" size="10"></td>
<td height="25" align="center">
<input name="ids" type="hidden" id="ids" value="<?php echo $myrow[id];?>">
<input name="qx" type="text" value="<?php echo $myrow[qx];?>" size="10">
</td>
<td height="25" align="center"><input type="submit" name="Submit2" value="删除">
<input type="submit" name="Submit4" value="修改"></td>
</tr>
<?php }?>
conn.php
<?php
$id=mysql_connect("localhost","root","root");
mysql_select_db("db_database04",$id);
mysql_query("set names gb2312");
?>
index.php
<?php session_start(); include("conn/conn.php");
if($user==true && $pass==true){
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>switch分支控制语句的应用</title>
<style type="text/css">
<!--
.STYLE1 {
font-size: 22px;
font-family: "华文行楷";
font-weight: bold;
color: #FFFFFF;
}
.STYLE6 {font-size: 13px; color: #FFFFFF; font-weight: bold; }
.STYLE7 {
font-size: 12px;
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head><body><table width="500" height="300" border="1" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" background="images/bg2.jpg" bgcolor="#2A81EA">
<tr>
<td height="50" colspan="4" align="center"><span class="STYLE1">数据库管理系统权限设置模块</span></td>
</tr>
<?php
$query=mysql_query("select * from tb_administrator where user='$user' and pass='$pass'");
$myrow=mysql_fetch_array($query);
$qxes=$myrow[qx];
switch($qxes){
case "0":
include("conn/0.inc");
break;
case "1":
include("conn/1.inc");
break;
case "2":
include("conn/2.inc");
break;
}
?>
<tr>
<td height="25" colspan="4" align="center"><span class="STYLE7">吉林省明日科技有限公司</span></td>
</tr>
</form>
</table>
</body>
</html>
<?php }else{
echo "<script> alert ('请您正确登录!'); window.location.href='indexes.php';</script>";
}
?>
index_ok.php
<?php session_start(); include("conn/conn.php");
if($Submit3=="创建"){
$query=mysql_query("insert into tb_administrator (user,pass,qx)values('$user','$pass','$qx')");
if($query==true){
echo "<script> alert ('用户创建成功!'); window.location.href='index.php';</script>";
}
}
if($Submit4=="修改"){
$update="update tb_administrator set user='$user',pass='$pass',qx='$qx' where id=$ids";
$result=mysql_query($update);
if($result==true){
echo "<script> alert ('修改成功!'); window.location.href='index.php';</script>";}
}
if($Submit2=="删除"){
$deletes="delete from tb_administrator where id='$ids'";
$results=mysql_query($deletes);
if($results==true){
echo "<script> alert ('删除成功!'); window.location.href='index.php';</script>";
}
}if($Submit==true){
$query=mysql_query("select * from tb_administrator where user='$user' and pass='$pass'");
$myrow=mysql_fetch_row($query);
if(count($myrow)>0){
session_register(user);
session_register(pass);
echo "<script> alert ('管理员登录成功!'); window.location.href='index.php';</script>";
}else{
session_unset(); //unset session variables.
session_destroy(); //end session we created earlier.
echo "<script> alert ('管理员登录失败!'); window.location.href='index.php';</script>";
}}
?>
indexes.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>switch分支控制语句的应用</title>
<style type="text/css">
<!--
.STYLE1 {
font-size: 13px;
color: #0D39A6;
font-weight: bold;
}
-->
</style>
</head><body><form name="form1" method="post" action="index_ok.php"><table width="471" height="275" border="0" cellpadding="0" cellspacing="0" background="images/bg.jpg">
<tr>
<td width="91" height="157"> </td>
<td width="114"> </td>
<td width="38"> </td>
<td width="67"> </td>
<td width="149"> </td>
</tr>
<tr>
<td height="34"> </td>
<td> </td>
<td> </td>
<td align="center"><span class="STYLE1"> 用户名:</span></td>
<td><input name="user" type="text" id="user" size="15"></td>
</tr>
<tr>
<td height="27"> </td>
<td align="right" class="STYLE1">密码: </td>
<td colspan="3"><input name="pass" type="password" id="pass" size="18">
<input name="Submit" type="submit" id="Submit" value="提交"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table></form>
</body>
</html>
image\
<td height="25" colspan="4" align="center"><span class="STYLE6">普通用户</span></td>
</tr>
<?php
$query="select * from tb_administrator ";
$result=mysql_query($query);
while($myrow=mysql_fetch_array($result)){
?>
<tr>
<td width="116" align="center"><span class="STYLE6"><?php echo $myrow[user];?></span></td>
<td width="97" align="center"><span class="STYLE6"><?php echo $myrow[pass];?></span></td>
<td height="25" colspan="2" align="center"><span class="STYLE6"><?php echo $myrow[qx];?></span></td>
</tr>
<?php }?>
conn\1.php
<tr>
<td height="25" colspan="4" align="center"><span class="STYLE6">管理员</span></td>
</tr>
<?php
if($Submit==true){
$query=mysql_query("insert into tb_administrator (user,pass,qx)values('$users','$passs','$pxs')");
if($query==true){
echo "<script>alert('普通用户创建成功!'); history.back();</script>";
}
}
$query="select * from tb_administrator ";
$result=mysql_query($query);
while($myrow=mysql_fetch_array($result)){
?>
<tr>
<td align="center"><span class="STYLE6"><?php echo $myrow[user];?></span></td>
<td align="center"><span class="STYLE6"><?php echo $myrow[pass];?></span></td>
<td height="25" colspan="2" align="center"><span class="STYLE6"><?php echo $myrow[qx];?></span></td>
</tr>
<?php }?>
<form name="form1" method="post" action="index.php">
<tr>
<td align="center"><input name="users" type="text" id="users" size="10"></td>
<td align="center"><input name="passs" type="text" id="passs" size="10">
<input name="pxs" type="hidden" id="pxs" value="0"></td>
<td height="25" colspan="2" align="center"><input name="Submit" type="submit" value="创建"></td>
</tr>
</form>
conn\2.ini
<tr>
<td height="25" colspan="4" align="center"><span class="STYLE6">超级管理员</span></td>
</tr>
<tr>
<td align="center" class="STYLE6">用户名</td>
<td align="center" class="STYLE6">密码</td>
<td width="127" height="25" align="center" class="STYLE6">权限</td>
<td width="137" align="center" class="STYLE6"> </td>
</tr>
<form name="form2" method="post" action="index_ok.php">
<tr>
<td align="center"><input name="user" type="text" id="user" size="10"></td>
<td align="center"><input name="pass" type="text" id="pass" size="10"></td>
<td height="25" align="center"><input name="qx" type="text" id="qx" size="10"> </td>
<td height="25" align="center"><span class="STYLE6">
<input type="submit" name="Submit3" value="创建">
</span></td>
</tr>
</form>
<form name="form3" method="post" action="index_ok.php">
<?php
$query="select * from tb_administrator ";
$result=mysql_query($query);
while($myrow=mysql_fetch_array($result)){
?>
<tr>
<td align="center">
<input name="user" type="text" id="user" value="<?php echo $myrow[user];?>" size="10"></td>
<td align="center">
<input name="pass" type="text" id="pass" value="<?php echo $myrow[pass];?>" size="10"></td>
<td height="25" align="center">
<input name="ids" type="hidden" id="ids" value="<?php echo $myrow[id];?>">
<input name="qx" type="text" value="<?php echo $myrow[qx];?>" size="10">
</td>
<td height="25" align="center"><input type="submit" name="Submit2" value="删除">
<input type="submit" name="Submit4" value="修改"></td>
</tr>
<?php }?>
conn.php
<?php
$id=mysql_connect("localhost","root","root");
mysql_select_db("db_database04",$id);
mysql_query("set names gb2312");
?>
index.php
<?php session_start(); include("conn/conn.php");
if($user==true && $pass==true){
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>switch分支控制语句的应用</title>
<style type="text/css">
<!--
.STYLE1 {
font-size: 22px;
font-family: "华文行楷";
font-weight: bold;
color: #FFFFFF;
}
.STYLE6 {font-size: 13px; color: #FFFFFF; font-weight: bold; }
.STYLE7 {
font-size: 12px;
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head><body><table width="500" height="300" border="1" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" background="images/bg2.jpg" bgcolor="#2A81EA">
<tr>
<td height="50" colspan="4" align="center"><span class="STYLE1">数据库管理系统权限设置模块</span></td>
</tr>
<?php
$query=mysql_query("select * from tb_administrator where user='$user' and pass='$pass'");
$myrow=mysql_fetch_array($query);
$qxes=$myrow[qx];
switch($qxes){
case "0":
include("conn/0.inc");
break;
case "1":
include("conn/1.inc");
break;
case "2":
include("conn/2.inc");
break;
}
?>
<tr>
<td height="25" colspan="4" align="center"><span class="STYLE7">吉林省明日科技有限公司</span></td>
</tr>
</form>
</table>
</body>
</html>
<?php }else{
echo "<script> alert ('请您正确登录!'); window.location.href='indexes.php';</script>";
}
?>
index_ok.php
<?php session_start(); include("conn/conn.php");
if($Submit3=="创建"){
$query=mysql_query("insert into tb_administrator (user,pass,qx)values('$user','$pass','$qx')");
if($query==true){
echo "<script> alert ('用户创建成功!'); window.location.href='index.php';</script>";
}
}
if($Submit4=="修改"){
$update="update tb_administrator set user='$user',pass='$pass',qx='$qx' where id=$ids";
$result=mysql_query($update);
if($result==true){
echo "<script> alert ('修改成功!'); window.location.href='index.php';</script>";}
}
if($Submit2=="删除"){
$deletes="delete from tb_administrator where id='$ids'";
$results=mysql_query($deletes);
if($results==true){
echo "<script> alert ('删除成功!'); window.location.href='index.php';</script>";
}
}if($Submit==true){
$query=mysql_query("select * from tb_administrator where user='$user' and pass='$pass'");
$myrow=mysql_fetch_row($query);
if(count($myrow)>0){
session_register(user);
session_register(pass);
echo "<script> alert ('管理员登录成功!'); window.location.href='index.php';</script>";
}else{
session_unset(); //unset session variables.
session_destroy(); //end session we created earlier.
echo "<script> alert ('管理员登录失败!'); window.location.href='index.php';</script>";
}}
?>
indexes.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>switch分支控制语句的应用</title>
<style type="text/css">
<!--
.STYLE1 {
font-size: 13px;
color: #0D39A6;
font-weight: bold;
}
-->
</style>
</head><body><form name="form1" method="post" action="index_ok.php"><table width="471" height="275" border="0" cellpadding="0" cellspacing="0" background="images/bg.jpg">
<tr>
<td width="91" height="157"> </td>
<td width="114"> </td>
<td width="38"> </td>
<td width="67"> </td>
<td width="149"> </td>
</tr>
<tr>
<td height="34"> </td>
<td> </td>
<td> </td>
<td align="center"><span class="STYLE1"> 用户名:</span></td>
<td><input name="user" type="text" id="user" size="15"></td>
</tr>
<tr>
<td height="27"> </td>
<td align="right" class="STYLE1">密码: </td>
<td colspan="3"><input name="pass" type="password" id="pass" size="18">
<input name="Submit" type="submit" id="Submit" value="提交"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table></form>
</body>
</html>
image\
$query=mysql_query("insert into tb_administrator (user,pass,qx)values('{$_POST['users']}','{$_POST['passs']}','{$_POST['pxs']}')");
if($query==true){
echo "<script>alert('普通用户创建成功!'); history.back();</script>";
}
}
if($_POST['Submit3']=="创建"){if($_POST['Submit2']=="删除"){if($_POST['Submit4']=="修改"){
问题比较多,LZ获取表单提交过来的数据,不要直接 $表单元素的name,这样获取不到的。
如果是GET请求用$_GET['表单元素的name']
如果是POST请求用$_POST['表单元素的name']
或者统一用
$_REQUEST['表单元素的name']