<?php include "base.php"; ?> <?php //if no session go to mainpage if(!$_SESSION['Username']){ header('location:index.php'); } //if ssesion is admin access accepted if($_SESSION['privilege'] == 'admin' ){ // header('location:adminpanel.php'); } //if not access is deny else { header('Location: login.php'); } ?> <!doctype html> <html> <head> <title>Admin Panel</title> </head> <body> Hai <?=$_SESSION['Username']?>,<br> Welcome on admin panel..<br><br> <?php $result = mysql_query("SELECT * FROM users"); echo "<table border='1'> <tr> <th>User ID</th> <th>Username</th> <th>Password</th> <th>Email Address</th> <th>Privelege</th> <th>Setting</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['UserID'] . "</td>"; echo "<td>" . $row['Username'] . "</td>"; echo "<td>" . $row['Password'] . "</td>"; echo "<td>" . $row['EmailAddress'] . "</td>"; echo "<td>" . $row['privilege'] . "</td>"; echo "<td><a href=\"adminedit.php?id=$row[UserID]\">Edit</a></td>"; echo "</tr>"; } echo "</table><br>"; if (!isset($_SESSION['count'])) { $_SESSION['count'] = 0; } else { $_SESSION['count']++; } echo "you have been login to this page " . $_SESSION['count']." times"; echo "<br>"; echo "Kita kenali Anda sebagai: <br><br>" .session_id(); ?> <br><br><A href='logout.php'>logout</A><br><br> </body> </html>
<?php include "base.php"; $id = $_GET["id"]; ?> <!DOCTYPE HTML> <html> <head> <title>Form Edit Data</title> </head> <body> <table border=1> <tr> <td align=center>Form Edit Data</td> </tr> <?php $result = mysql_query("SELECT * FROM users where UserID='$id'"); while($row = mysql_fetch_array($result)) { $nama = $row['Username']; $pass = $row['Password']; $email = $row['EmailAddress']; $privilege = $row['privilege']; } ?> <tr><td> <?php if(isset($_POST['submit'])) { $id = $_POST["id"]; $name = $_POST["username"]; $password = $_POST["password"]; $emailaddress = $_POST["email"]; $privilege = $_POST["privilege"]; $sql = "UPDATE users SET Username='$name', Password='$password', EmailAddress='$emailaddress', privilege='$privilege' WHERE UserID='$id'"; $result=mysql_query($sql); if($result){ echo "Successful"; echo "<BR>"; header('location:adminpanel.php'); echo "<a href='adminpanel.php'>View result</a>"; } else { echo "ERROR"; } } ?> <table> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="id" value="<? echo $id;?>"> <tr> <td>Username</td> <td> <input type="text" name="username" size="80" value="<?php echo $nama;?>"> </td> </tr> <tr> <td>Password</td> <td> <input type="text" name="password" size="80" value="<?php echo $pass;?>"> </td> </tr> <tr> <td>Email Address</td> <td> <input type="text" name="email" size="80" value="<?php echo $email;?>"> </td> </tr> <tr> <td>Privilege</td> <td> <input type="text" name="privilege" size="80" value="<?php echo $privilege?>"> </td> </tr> <tr> <td align="left"> <input type="submit" name="submit" value="Edit"> </td> </tr> </form> </table> </td></tr> </table> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)