Advertisement
Guest User

Untitled

a guest
May 30th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. <?php
  2. if($_GET['msg'])
  3. {
  4. $uid=$_SESSION['userid'];
  5. $user=mysql_query("select * from tb_user where id=$uid");
  6. while($userData=mysql_fetch_array($user))
  7. {
  8. $uname=$userData['user_name'];
  9. $udept=$userData['dept_id'];
  10. $usr_typeid=$userData['user_type'];
  11. $upasswd=$userData['password'];
  12. }
  13. }
  14. if($_POST['submit'])
  15. {
  16. /*$updated=false;
  17. if($_POST['id']<>"")
  18. {
  19. $query="update tb_user set user_name='".$_POST['username']."',dept_id=".$_POST['dept_id'].",user_type=".$_POST['usertype'].",password='".$_POST['password']."' where id=".$_POST['id'];
  20. $updated=true;
  21. }
  22. else
  23. {
  24. $query="insert into tb_user(user_name,password,dept_id,user_type) values('".addslashes($_POST['username'])."','".addslashes($_POST['password'])."',".$_POST['dept_id'].",".$_POST['usertype'].")";
  25. }
  26. $result=mysql_query($query);
  27. if($updated)
  28. {
  29. $_SESSION['deptid']=$_POST['dept_id'];
  30. $_SESSION['usertype']=$_POST['usertype'];
  31. header("Location: index.php?msg=Record updated");
  32. }
  33. else
  34. {
  35. header("Location: index.php?msg=Record created");
  36. }*/
  37. header("Location:index.php?page=request");
  38. }
  39. ?>
  40. <form method="post">
  41. <input type="hidden" name="id" value="<?php echo $uid?>"></input><br>
  42. User Type:
  43. <select name="usertype">
  44. <?php
  45. $utype=mysql_query('select * from tb_usertype');
  46. while($userData=mysql_fetch_array($utype))
  47. {
  48. if($usr_typeid==$userData[0])
  49. {
  50. ?>
  51. <option value="<?php echo $userData['id'];?>" selected="selected"><?php echo $userData['name'];?></option>
  52. <?php
  53. }
  54. else
  55. {
  56. ?>
  57. <option value="<?php echo $userData['id'];?>"><?php echo $userData['name'];?></option>
  58. <?php
  59. }
  60. }
  61. ?>
  62. </select><br>
  63. User Name: <input type="text" name="username" value="<?php echo $uname?>"></input><br>
  64. Password: <input type="password" name="password" value="<?php echo $upasswd?>"></input><br>
  65. Department: <select name="dept_id">
  66. <?php
  67. $utype=mysql_query('select * from tb_dept');
  68. while($userData=mysql_fetch_array($utype))
  69. {
  70. if($udept==$userData[0])
  71. {
  72. ?>
  73. <option value="<?php echo $userData['id'];?>" selected="selected"><?php echo $userData['dept_name'];?></option>
  74. <?php
  75. }
  76. else
  77. {
  78. ?>
  79. <option value="<?php echo $userData['id'];?>"><?php echo $userData['dept_name'];?></option>
  80. <?php
  81. }
  82. }
  83. ?>
  84. </select><br>
  85. <input type="submit" name="submit" value="Add"></input>
  86. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement