码迷,mamicode.com
首页 > Web开发 > 详细

php后台增删改跳转

时间:2016-12-19 13:47:58      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:log   href   image   com   ++   orm   代号   ble   into   

 

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 "删除失败";
	}
?>

  

技术分享

技术分享

 

php后台增删改跳转

标签:log   href   image   com   ++   orm   代号   ble   into   

原文地址:http://www.cnblogs.com/cyrfr/p/6197065.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!