Advertisement
Guest User

Untitled

a guest
Sep 12th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. <center><br/><h2>Update Form</h2></center>
  2. <div id="login">
  3. <fieldset>
  4. <legend><h3>Update Form</h3></legend>
  5. <h4 style="color:pink;"><?php global $nam; echo $nam;?> </h4>
  6. <?php global $error; echo $error;?>
  7. <!-- the login form-->
  8. <form action='login_reg_action.php' method='post' id='myform'>
  9. <div class="login">
  10. <table width="400px">
  11.  
  12. <tr>
  13. <td><label>Username</label></td>
  14. <td colspan="2"><span class="style8">
  15. <div align="center">
  16. <?php
  17. include 'connection.php';
  18. $sql = 'SELECT * FROM login_1 ORDER BY username';
  19. $sele=mysqli_query($conn,$sql);
  20. ?>
  21. <select name="login_id" style="width:250px; height:34px; border:1px solid #336666;">
  22. <option required="required" value="000" > [SELECT STUDENT]</option>
  23. <?php
  24. while($numu=mysqli_fetch_array($sele))
  25. {
  26. ?>
  27. <option required="required" value="<?php echo $numu['login_id'];?> "> <?php echo $numu["login_id"];echo' - ';echo $numu["username"] ?> </option>
  28. <?php
  29. }
  30. ?>
  31. </select>
  32. </label>
  33. </div>
  34. </td>
  35.  
  36. </tr>
  37. <tr>
  38. <td><label>Rank</label></td>
  39. <td><select name="rank" id="rank" style="width:250px; height:34px; border:1px solid #336666;">
  40. <option value="000">Choose user rank</option>
  41. <option value="student">Student</option>
  42. <option value="candidate">Candidate</option>
  43. <option value="administrator">Administrator</option>
  44. </select></td>
  45. </tr>
  46. <tr><td colspan="2" align="left"><input type="submit" name="submit" value="Update" style="width:100px; height:34px; border:1px solid #336666; border-radius:4px;"></td></tr>
  47. </table>
  48. </div>
  49. </form>
  50.  
  51. <?php
  52.  
  53. $servername="localhost";
  54. $username="root";
  55. $password="";
  56. $dbname="o-voting_db";
  57. //Create connection
  58. $con=mysqli_connect($servername,$username,$password,$dbname);
  59.  
  60.  
  61. $name = $_POST['login_id'];
  62. $rank = $_POST['rank'];
  63.  
  64.  
  65.  
  66. if(!$name || !$rank){
  67. $error="Please fill empty fields";
  68. include"login_reg.php";
  69. exit();
  70. }
  71. if(isset($_POST['submit'])) {
  72. $sql1="UPDATE login_1 SET rank='$rank' WHERE username='$name'";
  73.  
  74.  
  75. // if($rank=='candidate'){
  76. //include 'reg_cand.php';
  77. //}
  78.  
  79. $result = mysqli_query($con,$sql1)or die(mysqli_error($sql1));
  80.  
  81. if(!$result){
  82. die("Could not update data: " .mysqli_error($con));
  83. }
  84. else{
  85. $nam="<center><h4><font color='#00FF00'>Successful update,</h4></center> </font>";
  86. include "login_reg.php";
  87. }
  88. }
  89.  
  90.  
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement