Guest User

Untitled

a guest
Apr 23rd, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. HTML FILE:
  2. <form method="POST" action="../../php/AddLead.php">
  3. <div class="form-group">
  4. <label>Customer Comment</label>
  5. <textarea class="form-control" rows="2" name="lead_comment"></textarea>
  6. </div>
  7. <div class="form-group">
  8. <label>Admin Comment</label>
  9. <textarea class="form-control" rows="2" name="lead_admin_comment"></textarea>
  10. </div>
  11. <button type="submit" class="btn btn-default" id="addnewlead">Submit Details</button>
  12. <button type="reset" class="btn btn-default">Reset Fields</button>
  13. </form>
  14.  
  15. PHP FILE:
  16.  
  17. <?php
  18. session_start();
  19.  
  20. $servername = "localhost";
  21. $username = "username";
  22. $password = "password";
  23. $dbname = "myDB";
  24.  
  25. $conn = new mysqli($servername, $username, $password, $dbname);
  26.  
  27. if ($conn->connect_error) {
  28. die("Connection failed: " . $conn->connect_error);
  29. } else {
  30.  
  31. $lead_comment = mysqli_real_escape_string($conn, $_POST['lead_comment']);
  32.  
  33. $admin_comment = mysqli_real_escape_string($conn, $_POST['lead_admin_comment']);
  34.  
  35. $insert_query = "INSERT INTO `LeadTB` (`date`,`lead_comment`,`lead_admin_comm`)
  36. VALUES (CURDATE(),'" . $lead_comment . "','" . $admin_comment. "')";
  37.  
  38. if($conn->query($insert_query) === TRUE) {
  39. if($_SESSION['position'] == 'Marketing') {
  40. echo "<script>alert('Lead created successfully!');window.location.href='../Pages/Marketing/Leads.php';</script>";
  41. } elseif($_SESSION['position'] == "Lead Admin") {
  42. echo "<script>alert('Lead created successfully!');window.location.href='../Pages/Lead-Admin/Leads.php';</script>";
  43. } else {
  44. echo "<script>alert('You do not have access to the Marketing profile! Please contact an administrator.');window.location.href='../Pages/LoginError.html;</script>";
  45. }
  46.  
  47. } else {
  48. if($_SESSION['position'] == "Marketing") {
  49. echo "<script>alert('There was a problem with the lead creation process. Please try again.');window.location.href='../Pages/Marketing/Add-New-Lead.php';</script>";
  50. } else {
  51. echo "<script>alert('There was a problem with the lead creation process. Please try again.');window.location.href='../Pages/Lead-Admin/Add-New-Lead.php';</script>";
  52. }
  53. }
  54. }
  55. $conn->close();
  56. }
Add Comment
Please, Sign In to add comment