Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. <?php
  2. include "db.php";
  3.  
  4. $srcUserid = "";
  5. $srcName = "";
  6. $srcPassword = "";
  7. $srcLevel = "";
  8. $srcStatus = "";
  9.  
  10.  
  11.  
  12. if( isset($_POST["btnAdd"]) ){
  13. $vUserid = $_POST["txtuserid"];
  14. $vName = $_POST["txtname"];
  15. $vPassword = $_POST["txtpassword"];
  16. $vLevel = $_POST["txtlevel"];
  17. $vStatus = $_POST["txtstatus"];
  18.  
  19. $vSQL = " Insert Into usermaster ";
  20. $vSQL .= " ( userid, username, password, userlevel, status ) ";
  21. $vSQL .= " values( '$vUserid','$vName','$vPassword','$vLevel','$vStatus' ) ";
  22.  
  23. $db = new DB;
  24. $db->InsertRecord($vSQL);
  25. $db->CloseDB();
  26.  
  27. echo "Record Saved!";
  28. }
  29.  
  30. if( isset($_POST["btnUpdate"]) ){
  31. $vUserid = $_POST["txtuserid"];
  32. $vName = $_POST["txtname"];
  33. $vPassword = $_POST["txtpassword"];
  34. $vLevel = $_POST["txtlevel"];
  35. $vStatus = $_POST["txtstatus"];
  36.  
  37. $vSQL = " Update usermaster Set ";
  38. $vSQL .= " username = '$vName', ";
  39. $vSQL .= " password = '$vPassword', ";
  40. $vSQL .= " userlevel = '$vLevel', ";
  41. $vSQL .= " status = '$vStatus' ";
  42. $vSQL .= " where userid='$vUserid' ";
  43.  
  44. $db = new DB;
  45. $db->UpdateRecord($vSQL);
  46. $db->CloseDB();
  47.  
  48. echo "Record Updated!";
  49. }
  50.  
  51.  
  52. if( isset($_POST["btnDelete"]) ){
  53. $vUserid = $_POST["txtuserid"];
  54.  
  55. $vSQL = " Delete From usermaster ";
  56. $vSQL .= " where userid='$vUserid' ";
  57.  
  58. $db = new DB;
  59. $db->DeleteRecord($vSQL);
  60. $db->CloseDB();
  61.  
  62. echo "Record Deleted!";
  63. }
  64.  
  65.  
  66. if( isset($_POST["btnSearch"]) ){
  67.  
  68. $vUserid = $_POST["txtuserid"];
  69. $vSQL = " Select * from usermaster where userid = '$vUserid ' ";
  70. $db = new DB;
  71. $rs = $db->GetResult($vSQL);
  72.  
  73. while( $row = mysql_fetch_array($rs) ){
  74. $srcUserid = $row["userid"];
  75. $srcName = $row["username"];
  76. $srcPassword = $row["password"];
  77. $srcLevel = $row["userlevel"];
  78. $srcStatus = $row["status"];
  79. }
  80. $db->CloseDB();
  81. }
  82. ?>
  83. <html>
  84. <head>
  85. <title>Untitled Document</title>
  86. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  87. </head>
  88. <body>
  89. <center>
  90. <style>
  91. div {
  92.  
  93. border-width: 1px;
  94. background-color: lightblue;
  95. }
  96. div#aaa{
  97.  
  98. border-width: 5px;
  99. background-color: lightgreen;
  100. }
  101. </style>
  102. <div>
  103. <table>
  104. <form method="post">
  105. <tr>
  106. <td>User ID : </td><td><input required type="text" name="txtuserid" value="<?php echo $srcUserid; ?>" /></td><td>[<input type="submit" name="btnSearch" value="Search" />]</td>
  107. </tr>
  108. <tr>
  109. <td>Name : </td><td><input type="text" name="txtname" value="<?php echo $srcName; ?>" /></td><td></td>
  110. </tr>
  111. <tr>
  112. <td>Password :</td><td><input type="text" name="txtpassword" value="<?php echo $srcPassword; ?>" /></td><td></td>
  113. </tr>
  114. <tr>
  115. <td>Level :</td><td><input type="text" name="txtlevel" value="<?php echo $srcLevel; ?>" /></td><td></td>
  116. </tr>
  117. <tr>
  118. <td>Status :</td><td><input type="text" name="txtstatus" value="<?php echo $srcStatus; ?>" /></td><td></td>
  119. </tr>
  120. <tr>
  121. <td></td>
  122. <td>
  123. <input type="submit" name="btnAdd" value="Add" />
  124. <input type="submit" name="btnUpdate" value="Update" />
  125. <input type="submit" name="btnDelete" value="Delete" />
  126. </td>
  127. <td></td>
  128. </tr>
  129. </form>
  130. </table>
  131. </div>
  132. <div id=aaa>
  133. <?php include "usermaster.php"; ?>
  134. </div>
  135. </center>
  136. </body>
  137. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement