Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.56 KB | None | 0 0
  1. //update proccess
  2. <?php
  3.  
  4. $serverName = "localhost";
  5. try{
  6. $db= new PDO( "sqlsrv:server=$serverName ; Database=systems_requests", "test", "test");
  7. $db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
  8.  
  9. $sql = 'UPDATE requests Set name= :name, lanId= :lanId, department= :department,manager= :manager,request= :request,request_comments= :request_comments,status= :status,comments= :comments,compUser= :compUser, compDt= :compDt WHERE id= :id';
  10. $stmt = $db->prepare($sql);
  11. $stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
  12. $stmt->bindParam(':lanId', $_POST['lanId'], PDO::PARAM_STR);
  13. $stmt->bindParam(':name', $_POST['name'], PDO::PARAM_STR);
  14. $stmt->bindParam(':department', $_POST['department'], PDO::PARAM_STR);
  15. $stmt->bindParam(':manager', $_POST['manager'], PDO::PARAM_STR);
  16. $stmt->bindParam(':request', $_POST['request'], PDO::PARAM_STR);
  17. $stmt->bindParam(':request_comments', $_POST['request_comments'], PDO::PARAM_STR);
  18. $stmt->bindParam(':status', $_POST['status'], PDO::PARAM_STR);
  19. $stmt->bindParam(':comments', $_POST['comments'], PDO::PARAM_STR);
  20. $stmt->bindParam(':compUser', $_POST['compUser'], PDO::PARAM_STR);
  21. $stmt->bindParam(':compDt', $_POST['compDt'], PDO::PARAM_INT);
  22. $stmt->execute();
  23.  
  24.  
  25.  
  26.  
  27.  
  28. $to = $_POST['lanId'] . "@exchange.test.com";
  29. $subject = "Request";
  30. $headers = "From: test@test.com";
  31.  
  32. $message ="LanID: " . $_POST['lanId'] . "
  33.  
  34.  
  35. " ."User Name: ". $_POST['name'] ."
  36.  
  37. ". "Department: " . $_POST['department'] . "
  38.  
  39. " ."Manager: ". $_POST['manager'] . "
  40.  
  41. ". "User Request: " . $_POST['request'] . "
  42.  
  43. " ."User Request comments: ". $_POST['request_comments']. "
  44.  
  45. " ."Status: " . $_POST['status'] . "
  46.  
  47. " ."Systems comments: ". $_POST['comments'] . "
  48.  
  49. " ."Completed by: ". $_POST['compUser'] ;
  50.  
  51. mail($to,$subject,$message,$headers);
  52. }catch(PDOException $exception){
  53. echo "Error: " . $exception->getMessage();
  54. }
  55. ?>
  56.  
  57. //start of form to select the id to update
  58. <?php
  59. include('db_connect.php');
  60. $id=$_GET['id'];
  61. $result = $db->prepare("SELECT * FROM requests WHERE id= :id");
  62. $result->bindParam(':id', $id);
  63. $result->execute();
  64. for($i=0; $row = $result->fetch(); $i++){
  65. ?>
  66.  
  67. <html>
  68. <head>
  69. <title></title>
  70.  
  71. <style type="text/css">
  72.  
  73. }
  74. .body{
  75. background-color: #F2F2F2;
  76. border: thin solid #666666;
  77. }
  78. </style>
  79.  
  80. </head>
  81. <body class='body'>
  82. <form action = "update_process.php" method ="post" class="Form">
  83.  
  84. <p><input type ="hidden" name = "id" value="<?php print($id); ?>"</p>
  85.  
  86. <h2 align="center">Users request Information</h2>
  87. <table border='1' align="center">
  88. <tr>
  89. <td>LAN ID:</td>
  90. <td><input type="text" value ="<?php print($row['lanId']) ?>"name="lanId"></td>
  91.  
  92. <td>Name:</td>
  93. <td><input type="text" value ="<?php print($row['name']) ?>"name="name"></td>
  94. </tr>
  95.  
  96. <tr>
  97. <td>Department Location</td>
  98. <td><input type="text" value ="<?php print($row['department']) ?>"name="department"></td>
  99.  
  100. <td>Manager</td>
  101. <td><input type="text" value ="<?php print($row['manager']) ?>"name="manager"></td>
  102. </tr>
  103.  
  104.  
  105. <tr>
  106. <td>Request</td>
  107. <td><input type="text" value ="<?php print($row['request']) ?>"name="request"></td>
  108.  
  109. <td></td>
  110. <td></td>
  111.  
  112. </tr>
  113. </table>
  114. <h2 align='center'>Requested Comments</h2>
  115. <table border='1' align="center">
  116.  
  117.  
  118. <tr>
  119.  
  120. <td width='400' height="40">
  121. <textarea name="request_comments" style="width: 600px; height: 81px" style="text-transform:uppercase ;"><?php echo $row['request_comments']; ?></textarea></td>
  122.  
  123. </tr>
  124.  
  125. </table>
  126.  
  127.  
  128. <h2 align="center">Complete or Update Requests Status</h2>
  129.  
  130. <table border='1' align="center" style="width: 595px">
  131. <tr>
  132. <td>Completed Date</td>
  133. <td style="width: 303px">
  134. <input type="text" value ="<?php echo date("m/d/Y",time())?>"name="compDt" style="width: 148px"></td>
  135.  
  136.  
  137. </tr>
  138. <tr>
  139. <td>Status</td>
  140. <td style="width: 303px"><select name ="status" style="width: 149px" >
  141. <option value <?php if ($row['status']==1){ print('selected');} ?> ="Received">Received</option>
  142. <option value <?php if ($row['status']==2){ print('selected');} ?> ="Completed">Completed</option>
  143. <option value <?php if ($row['status']==3){ print('selected');} ?> ="Cancelled">Cancelled</option>
  144. <option value <?php if ($row['status']==4){ print('selected');} ?> ="In_Progress">In_Progress</option>
  145. <option value <?php if ($row['status']==5){ print('selected');} ?> ="On_Hold">On_Hold</option>
  146.  
  147. </select>
  148. </td>
  149. </tr>
  150. <tr>
  151. <td>Completed by</td>
  152. <td style="width: 303px"><select name ="compUser" style="width: 149px" >
  153. <option value <?php if ($row['compUser']==1){ print('selected');} ?> ="">Please Select....</option>
  154. <option value <?php if ($row['compUser']==1){ print('selected');} ?> ="xgrh">xgrh</option>
  155. <option value <?php if ($row['compUser']==2){ print('selected');} ?> ="zeap">zeap</option>
  156. <option value <?php if ($row['compUser']==2){ print('selected');} ?> ="xjae">xjae</option>
  157. <option value <?php if ($row['compUser']==5){ print('selected');} ?> ="zmoj">zmoj</option>
  158. </select>
  159. </td>
  160. </tr>
  161.  
  162.  
  163. </table>
  164. <div align='center'>
  165. <br>Systems Support Comments:<br>
  166. <textarea name="comments" Value = "<?php print($row['request_comments']) ?>" style="width: 593px; height: 90px"></textarea><br>
  167. <br>
  168.  
  169. <input type="submit" value= "Update Information">
  170. <br>
  171. </div>
  172. </form>
  173.  
  174.  
  175. </body>
  176. </html>
  177. <?php
  178. }
  179. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement