Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HTML FILE:
- <form method="POST" action="../../php/AddLead.php">
- <div class="form-group">
- <label>Customer Comment</label>
- <textarea class="form-control" rows="2" name="lead_comment"></textarea>
- </div>
- <div class="form-group">
- <label>Admin Comment</label>
- <textarea class="form-control" rows="2" name="lead_admin_comment"></textarea>
- </div>
- <button type="submit" class="btn btn-default" id="addnewlead">Submit Details</button>
- <button type="reset" class="btn btn-default">Reset Fields</button>
- </form>
- PHP FILE:
- <?php
- session_start();
- $servername = "localhost";
- $username = "username";
- $password = "password";
- $dbname = "myDB";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- } else {
- $lead_comment = mysqli_real_escape_string($conn, $_POST['lead_comment']);
- $admin_comment = mysqli_real_escape_string($conn, $_POST['lead_admin_comment']);
- $insert_query = "INSERT INTO `LeadTB` (`date`,`lead_comment`,`lead_admin_comm`)
- VALUES (CURDATE(),'" . $lead_comment . "','" . $admin_comment. "')";
- if($conn->query($insert_query) === TRUE) {
- if($_SESSION['position'] == 'Marketing') {
- echo "<script>alert('Lead created successfully!');window.location.href='../Pages/Marketing/Leads.php';</script>";
- } elseif($_SESSION['position'] == "Lead Admin") {
- echo "<script>alert('Lead created successfully!');window.location.href='../Pages/Lead-Admin/Leads.php';</script>";
- } else {
- echo "<script>alert('You do not have access to the Marketing profile! Please contact an administrator.');window.location.href='../Pages/LoginError.html;</script>";
- }
- } else {
- if($_SESSION['position'] == "Marketing") {
- 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>";
- } else {
- 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>";
- }
- }
- }
- $conn->close();
- }
Add Comment
Please, Sign In to add comment