Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.97 KB | None | 0 0
  1. listprofile.php
  2.  
  3. <?php
  4.     include "conf.php";
  5.  
  6.     $sql = "SELECT * FROM teacher";
  7.     $query = mysqli_query($conn, $sql);
  8.    
  9.     if(!$query){
  10.         echo "ไม่สามรถเรียกข้อมูลได้...";
  11.         echo "กรุณารอสักครู่...";
  12.         header('refresh: 3; url=./index.php');
  13.     }
  14. ?>
  15. ้<!DOCTYPE html>
  16. <html lang="en">
  17. <head>
  18.     <meta charset="UTF-8">
  19.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  20.     <meta http-equiv="X-UA-Compatible" content="ie=edge">
  21.     <link rel="stylesheet" href="css/list.css">
  22.     <title>รายการข้อมูลทั้งหมด</title>
  23.     <style>
  24.     body{
  25.         background-color: #668cff;
  26.         margin: 0;
  27.         padding: 0;
  28.         color: white;
  29.     }
  30.     .tb{
  31.         position: absolute;
  32.         top: 100px;
  33.         left: 30%;
  34.     }
  35.     table{
  36.         border: 1px solid black;
  37.         background-color: black;
  38.         width: 100%;
  39.        
  40.     }
  41.     .data{
  42.         background-color: white;
  43.         color: black;
  44.     }
  45.     button{
  46.         cursor: pointer;
  47.         background-color: blue;
  48.         color: white;
  49.         border-radius: 15%;
  50.         overflow: auto;
  51.     }
  52.     </style>
  53. </head>
  54. <body>
  55.     <div class="tb">
  56.         <table>
  57.         <tr>
  58.             <th>Username</th>
  59.             <th>Password</th>
  60.             <th>full Name</th>
  61.             <th>Department Name</th>
  62.             <th>photo</th>
  63.         </tr>
  64.         <?php
  65.             while($result = mysqli_fetch_array($query)){
  66.         ?>
  67.    
  68.         <tr class="data">
  69.             <td><?php echo $result['username'] ?></td>
  70.             <td><?php echo $result['password'] ?></td>
  71.             <td><?php echo $result['fullname'] ?></td>
  72.             <td><?php echo $result['depname'] ?></td>
  73.             <td><?php echo $result['photo'] ?></td>
  74.         </tr>
  75.         <?php
  76.         }
  77.         ?>
  78.     </table>
  79.     <a href="index.php">
  80.     <button type="submit">กลับไปหน้าแรก</button>
  81.     </a>
  82.     </div>
  83.     <?php
  84.         mysqli_close($conn);
  85.     ?>
  86.    
  87. </body>
  88. </html>
  89.  
  90. -----------------------------------------
  91. addprocess.php
  92.  
  93.  
  94. <?php
  95.  
  96.     include "conf.php";
  97.  
  98.     $usr = $_POST['usr'];
  99.     $pwd = $_POST['pwd'];
  100.     $dep = $_POST['dep'];
  101.     $fname = $_POST['fname'];
  102.     $photo = $_POST['photo'];
  103.  
  104.     $sql = "INSERT INTO teacher VALUES(0,'$usr','$pwd','$fname','$dep','$photo')";
  105.     $query = mysqli_query($conn,$sql);
  106.     //$result = mysql_fetch_array($query);
  107.     if($query){
  108.         echo "เพิ่มข้อมูลเรียบร้อยแล้ว";
  109.         echo "กรุณารอสักครู่...";
  110.         header('refresh: 3; url=./index.php');
  111.     }else{
  112.         echo "ไม่สามารถเพิ่มข้อมูลได้";
  113.         echo "กรุณารอสักครู่...";
  114.         header('refresh: 3; url=./index.php');
  115.     }
  116.  
  117.  
  118. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement