php登录页面:

<h1>登录界面</h1>
<form action="dengluchuli.php" method="post">
用户名:<input type="text" name="uid"/>
密码:<input type="text" name="pwd"/>
<input type="submit" value="登录" />
</form>

其中 dengluchuli.php在规定路径下。

登录跳转页面:

<?php
$yonghuming = $_POST["uid"];
$mima = $_POST["pwd"];
$db = new mysqli("localhost","root","","12345");
$sql = "select password from login where username='{$yonghuming}'";
$result = $db->query($sql);
$atter = $result->fetch_row();
if($atter[0]==$mima && !empty($mima))
{
header("location:xinxi.php");
}
else
{
echo "用户名或密码错误";
} ?>

  

此页面用于登录界面登录成功后通过用户名找到相应的数据。

登录主界面:

<?php
$de = new mysqli("localhost","root","","12345");
$e="select * from info";
$result = $de->query($e);
$atter = $result->fetch_all();
echo "<table border=1>";
echo "<tr>
<td>代号</td>
<td>姓名</td>
<td>性别</td>
<td>民族</td>
<td>出生日期</td>
<td>操作</td>
</tr> ";
for($i=0;$i<count($atter);$i++)
{
echo "<tr>";
for($j=0;$j<count($atter[$i]);$j++)
{
if($j==4)
{
echo "<td>".$atter[$i][$j]."</td> <td><a href='shanchu.php?code={$atter[$i][1]}' onclick=\"return confirm('确定删除?')\"> 删除</a></td>";
}
else
{
echo "<td>".$atter[$i][$j]."</td>";
}
}
echo "</tr>";
}
echo " </table>";
echo "<a href='tianjia.php'>添加数据</a>"
?>

  

添加数据(tianji.php):

 <h1>添加数据</h1>
<form action="zeng.php" method="post">
代号:<input type="text" name="daihao" /> <br />
姓名:<input type="text" name="xinming" /><br />
性别:<input type="text" name="xinbie" /><br />
民族:<input type="text" name="minzu" /><br />
生日:<input type="text" name="shengri" /><br />
<input type="submit" value="提交"/>
</form>

zeng.php :

<?php
$code = $_POST["daihao"];
$name = $_POST["xinming"];
$sex = $_POST["xinbie"];
$nation = $_POST["minzu"];
$birthday = $_POST["shengri"];
$db = new mysqli("localhost","root","","12345");
$sql = "insert into info values('{$code}','{$name}','{$sex}','{$nation}','{$birthday}')";
$r = $db->query($sql);
if($r)
{
header("location:xinxi.php");
}
else
{
echo "添加失败";
}
?>

  

  

添加成功:

shanchu.php

<?php

    $name = $_GET["code"];
$db = new mysqli("localhost","root","","12345");
$sql = "delete from info where name='{$name}'";
$result = $db->query($sql);
if($result)
{
header("location:xinxi.php");
}
else
{
echo "删除失败";
}
?>

  

 修改数据:

在xinxi.php文件中插入代码:

<a href='xiugai.php?code={$atter[$i][1]}'>修改</a>

  

相同路径下新建xiugai.php

<?php
$name = $_GET["code"];
$db = new mysqli("localhost","root","","12345");
$sql = "select * from info where name='{$name}'";
$r = $db->query($sql);
$atter = $r->fetch_row();
?>
<h1>修改</h1>
<form action="xiugaichuli.php" method="post">
<input type="hidden" name="daihao" value="<?php echo $atter[0]; ?>" /> <br />
姓名: <input type="text" name="xinming" value="<?php echo $atter[1]; ?>"/> <br />
性别: <input type="text" name="xinbie" value="<?php echo $atter[2]; ?>"/> <br />
民族: <input type="text" name="minzu" value="<?php echo $atter[3]; ?>"/> <br />
生日: <input type="text" name="shengri" value="<?php echo $atter[4]; ?>"/> <br />
<input type="submit" value="修改" />
</form>

  

相同路径下新建xiugaichuli.php

<?php
$code = $_POST["daihao"];
$name = $_POST["xinming"];
$sex = $_POST["xinbie"];
$nation = $_POST["minzu"];
$birthday = $_POST["shengri"];
$db = new mysqli("localhost","root","","12345");
$sql = "update info set name='{$name}',sex={$sex},nation='{$nation}',birthday='{$birthday}' where code='{$code}'";
$r = $db->query($sql);
if($r)
{
header("location:xinxi.php");
}
else
{
echo "修改失败";
}
?>

  

点击修改其中一条数据:

修改成功。

最新文章

  1. 文本框focus之后高亮背景颜色
  2. 虚拟机网络驱动(共享文件夹)不见了的解决方案-适用于win7~win10 and Windows Server 2008~Windows Server 2012R2
  3. php反射
  4. Windows程序设再读笔记01-起步
  5. Net分布式系统之五:C#使用Redis集群缓存
  6. [CF442B] Andrey and Problem (概率dp)
  7. Android IOS WebRTC 音视频开发总结(二一)-- 黑屏问题
  8. 对session和cookie的一些理解
  9. Hibernate4搭建Log4J日志管理(附Log4j.properties配置详解)
  10. Linux下Nginx+tomcat应用系统性能优化
  11. gradle构建android项目详解
  12. &lt;A&gt;标记onclick事件
  13. C# - 匿名对象属性的赋值与取值
  14. jsp标签jstl和el表达式
  15. qt 实现的电视遥控系统,如何让qt响应来自遥控器的按键信息?
  16. List与Array互相转换
  17. 做业5.2 TDD
  18. Python爬虫实战(三):爬网易新闻
  19. Redis 如何保持和MySQL数据一致
  20. centos6.2 下安装并配置hadoop1.0.4(32位安装)

热门文章

  1. SQL Server2014 SP2新增的数据库克隆功能
  2. 通过ProGet搭建一个内部的Nuget服务器
  3. html5标签canvas函数drawImage使用方法
  4. Android消息传递之基于RxJava实现一个EventBus - RxBus
  5. ASP.NET WebApi OWIN 实现 OAuth 2.0
  6. Aaron Stannard谈Akka.NET 1.1
  7. Python自然语言处理工具小结
  8. .Net语言 APP开发平台——Smobiler学习日志:手机应用的TextTabBar快速实现方式
  9. Flexible 弹性盒子模型之CSS flex-grow 属性
  10. ios label 自动计算行高详解