:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/public_html/crm/**
:: Editing File: upload_leads_csv.php
<?php ob_start(); include 'header.php'; $page_title = "Upload Leads (CSV)"; $page_parent = "Leads"; $page_parent_link = "leads.php"; include 'breadcrumb.php'; include('menu.php'); $message = ""; if (isset($_POST['upload'])) { if ($_FILES['csv_file']['error'] == 0) { $filename = $_FILES['csv_file']['tmp_name']; if (($handle = fopen($filename, "r")) !== FALSE) { // Skip header row fgetcsv($handle); $rowCount = 0; while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $lead_date = mysqli_real_escape_string($conn, $data[0]); $lead_source = mysqli_real_escape_string($conn, $data[1]); $name = mysqli_real_escape_string($conn, $data[2]); $mobile = mysqli_real_escape_string($conn, $data[3]); $location = mysqli_real_escape_string($conn, $data[4]); $email = mysqli_real_escape_string($conn, $data[5]); $business_name = mysqli_real_escape_string($conn, $data[6]); $enquiry_for = mysqli_real_escape_string($conn, $data[7]); $enquiry_content = mysqli_real_escape_string($conn, $data[8]); $comment = mysqli_real_escape_string($conn, $data[9]); $follow_up_date = mysqli_real_escape_string($conn, $data[10]); $calling_status = mysqli_real_escape_string($conn, $data[11]); $assigned_to = $_SESSION['user_id']; $created_by = $_SESSION['user_id']; // Insert record $sql = "INSERT INTO leads (lead_date, lead_source, name, mobile, location, email, business_name, enquiry_for, enquiry_content, comment, follow_up_date, calling_status, assigned_to, created_by) VALUES ('$lead_date', '$lead_source', '$name', '$mobile', '$location', '$email', '$business_name', '$enquiry_for', '$enquiry_content', '$comment', '$follow_up_date', '$calling_status', '$assigned_to', '$created_by')"; mysqli_query($conn, $sql); $rowCount++; } fclose($handle); $message = "✅ Successfully imported $rowCount leads!"; } else { $message = "❌ Unable to open CSV file."; } } else { $message = "⚠️ Please upload a valid CSV file."; } } ?> <div class="page-body"> <div class="container-fluid"> <div class="row"> <div class="col-sm-12"> <div class="card"> <div class="card-header pb-0"> <h2>Upload Leads (CSV Import)</h2> </div> <div class="card-body"> <?php if ($message) echo "<div class='alert alert-info'>$message</div>"; ?> <form method="POST" enctype="multipart/form-data"> <div class="mb-3"> <label class="form-label">Select CSV File</label> <input type="file" name="csv_file" accept=".csv" class="form-control" required> </div> <button type="submit" name="upload" class="btn btn-success">Upload & Import</button> <a href="leads.php" class="btn btn-secondary">Cancel</a> </form> <hr> <!--<h5>📋 CSV Format Example:</h5> <table class="table table-bordered"> <thead> <tr> <th>Lead Source</th> <th>Name</th> <th>Mobile</th> <th>Location</th> <th>Email</th> <th>Business Name</th> <th>Enquiry For</th> <th>Enquiry Content</th> <th>Comment</th> <th>Follow Up Date</th> <th>Calling Status</th> <th>Status</th> </tr> </thead> </table> <p>💡 Save your file as <strong>CSV (Comma delimited)</strong> before uploading.</p> --> </div> </div> </div> </div> </div> </div> <?php include 'footer.php'; ob_end_flush(); ?>