php後台增刪改跳轉

來源:互聯網
上載者:User

標籤: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後台增刪改跳轉

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.