Advertisement
Guest User

Untitled

a guest
Mar 8th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['insert'])){
  3.  
  4. $hostname = "localhost";
  5. $username = "root";
  6. $password = "";
  7. $databaseName = "change_management";
  8.  
  9. $connect = mysqli_connect($hostname, $username, $password, $databaseName);
  10.  
  11. $user = $_POST['user'];
  12. $passcode = $_POST['passcode'];
  13.  
  14.  
  15. $sql = "SELECT * FROM admin WHERE username = '" . $user . "' and passcode ='".md5($passcode)."'";
  16. $result = mysqli_query($connect,$sql);
  17. $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  18.  
  19. $count = mysqli_num_rows($result);
  20.  
  21. // If result match $myusername and $mypassword, table row must be 1 row
  22.  
  23. if($count ==0) {
  24. echo "<font color=red><strong>Authentication failed - Invalid credentials</font></strong><br><br>";
  25. }else {
  26.  
  27. $change_id = $_POST['change_id'];
  28. $approval_disposition = $_POST['approval_disposition'];
  29. $approval_reason = $_POST['approval_reason'];
  30. $approval_impact = $_POST['approval_impact'];
  31. $user = $_POST['user'];
  32. $approval_date = date('Y/m/d');
  33. $approval_expiry_date = date('Y/m/d', strtotime('+2 weeks'));
  34.  
  35.  
  36. $query = "UPDATE change_request_tbl SET approval_disposition='$approval_disposition', approval_reason='$approval_reason', approval_impact='$approval_impact', approval_name='$user', approval_date='$approval_date', approval_expiry_date='$approval_expiry_date' WHERE change_id='$change_id'";
  37. $query = "SELECT `change_requestor` FROM `change_request_tbl` WHERE `change_id` = $change_id";
  38. $result1 = mysqli_query($connect,$query);
  39.  
  40.  
  41. while ($row = mysqli_fetch_array($result1))
  42.  
  43.  
  44. $to = "******, ****, ****, *****, $row[change_requestor]";
  45. $subject = "New Change Acceptance Board (CAB) Approval";
  46. $message = "
  47. <html>
  48. <head>
  49. <style>
  50. body {font-family: Calibri;}
  51. body {font-style: italic;}
  52. .table {
  53. background-color: white;
  54. }
  55. </style>
  56. <title>Change Acceptance Board Approval</title>
  57. </head>
  58. <body>
  59. <p>A new Change Acceptance Board (CAB) Approval has been submitted:</p>
  60. <table border=4 bordercolor=black class=table>
  61. <tr>
  62. <th>Change ID:</th>
  63. <th>Disposition:</th>
  64. <th>Reason for Rejection or Exceptions:</th>
  65. <th>Impact (By CAB):</th>
  66. <th>Approved/Rejected by:</th>
  67. <th>Date Approved:</th>
  68. <th>Approval Expiry Date*:</th>
  69. </tr>
  70. <tr>
  71. <td>$change_id</td>
  72. <td>$approval_disposition</td>
  73. <td>$approval_reason</td>
  74. <td>$approval_impact</td>
  75. <td>$user</td>
  76. <td>$approval_date</td>
  77. <td>$approval_expiry_date</td>
  78. </tr>
  79. </table>
  80. <p>*This change must be completed by the Expiry Date. If this is not achieved a second CAB Request must be raised referencing this Change ID.</p>
  81. </body>
  82. </html>
  83. ";
  84.  
  85. $headers = "MIME-Version:1.0" . "rn";
  86. $headers .= "Content-type:text/html;charset=UTF-8" . "rn";
  87. $headers .='From: <******>' . "rn";
  88.  
  89. mail($to,$subject,$message,$headers);
  90. echo "Your CAB Approval Form has been submitted. You will receive an email confirmation shortly.<br><br>";
  91. }
  92.  
  93. }
  94.  
  95. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement