Advertisement
Guest User

Untitled

a guest
Jun 9th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.13 KB | None | 0 0
  1. <?php
  2.     include('connect.php');
  3.     if(isset($_POST['UserID'])) {
  4.         $sql_insert = sqlquery("UPDATE User SET LoginName='{$_POST['LoginName']}', FirstName='{$_POST['FirstName']}', SurName='{$_POST['SurName']}', Password='{$_POST['Password']}' WHERE UserID='{$_POST['UserID']}'");
  5.         $message = "<script>alert('User updated.');</script>";
  6.     }
  7. ?>
  8. <!DOCTYPE html>
  9. <html lang="en">
  10. <head>
  11.     <link rel="stylesheet" type="text/css" href="cssmain.css">
  12.     <meta charset="UTF-8">
  13.     <title>Edit User</title>
  14. </head>
  15. <body>
  16.     <div class="navbar" align="left">
  17.         <ul>
  18.             <li><a href="index.php">Home</a></li>
  19.             <li><a href="addGrade.php">Add Grade</a></li>
  20.             <li><a class="active" href="addUser.php">Add User</a></li>
  21.             <li><a href="addCourse.php">Add Course</a></li>
  22.             <li><a href="login.php">Login</a></li>
  23.         </ul>
  24.     </div>
  25.     <div>
  26.         <div align="left" class="blackline"></div>
  27.     </div>
  28.     <div align="center" class="content">
  29.         <?php
  30.             if(isset($_SESSION['username'])) {
  31.                 echo 'Username: <b>'.$_SESSION['username'].'</b>, <a href="logout.php">logout</a>';
  32.             }
  33.  
  34.         ?>
  35.         <h1>Edit User</h1>
  36.         <p>Adding and edditing BTEC somester content</p>
  37.  
  38.         <?php
  39.             if(!empty($_POST)) {
  40.                 if(isset($_POST['selectstudent'])) {
  41.                     echo '
  42.                         <form method="post" action="edit.php">
  43.                             <br><h3>Edit:</h3>
  44.                             <input type="hidden" name="UserID"><br>
  45.                             First Name:
  46.                             <input type="text" name="FirstName"><br>
  47.                             Surname:
  48.                             <input type="text" name="SurName"><br>
  49.                             Username:
  50.                             <input type="text" name="LoginName"><br>
  51.                             Password:
  52.                             <input type="text" name="Password"><br>
  53.                             <input type="submit" value="Update"><br>
  54.                         </form>
  55.                     ';
  56.                 }
  57.             } else {
  58.                 $sql =  sqlquery("SELECT UserID, LoginName FROM User");
  59.                 echo '<form action="userEditted.php" method="POST">';
  60.                 echo '<select name="options">';
  61.                 while ($row = mysqli_fetch_array($sql)) {
  62.                 echo '<option value="'.$row['UserID'].'">' . $row['LoginName'] . '</option>';
  63.                 }
  64.                 echo '</select>';
  65.                 echo '<input type="submit" value="Select" name="selectstudent">'
  66.                 echo '</form>';
  67.             }
  68.  
  69.         ?>
  70.     </div>
  71.    
  72. </body>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement