:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/public_html/kreative_crm/**
:: Editing File: vcard_testimonial_add.php
<?php ob_start(); include 'header.php'; $page_title = "Add VCard Testimonial"; $page_parent = "VCards"; $page_parent_link = "vcard_list.php"; include 'breadcrumb.php'; include 'menu.php'; $message = ""; /* ✅ Handle Form Submit */ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $vcard_id = intval($_POST['vcard_id']); $client_name = mysqli_real_escape_string($conn, $_POST['client_name']); $msg = mysqli_real_escape_string($conn, $_POST['message']); $status = isset($_POST['status']) ? 1 : 0; if ($vcard_id == 0 || $client_name == '') { $message = "VCard and Client Name are required."; } /* ✅ Get card_slug (IMPORTANT) */ if ($message == '') { $vcard_q = mysqli_query( $conn, "SELECT card_slug FROM vcards WHERE id='$vcard_id'" ); $vcard = mysqli_fetch_assoc($vcard_q); if (!$vcard) { $message = "Invalid VCard selected."; } } /* ✅ Create testimonial directory */ if ($message == '') { $slug = $vcard['card_slug']; $base_dir = "uploads/vcard/" . $slug . "/testimonial/"; if (!is_dir($base_dir)) { mkdir($base_dir, 0777, true); } } /* ✅ Image Upload */ $client_image = NULL; $allowed_ext = ['jpg','jpeg','png','webp']; if ($message == '' && !empty($_FILES['client_image']['name'])) { $ext = strtolower(pathinfo($_FILES['client_image']['name'], PATHINFO_EXTENSION)); if (!in_array($ext, $allowed_ext)) { $message = "Only JPG, PNG, WEBP images allowed."; } else { $client_image = time() . '_' . rand(100,999) . '.' . $ext; move_uploaded_file( $_FILES['client_image']['tmp_name'], $base_dir . $client_image ); } } /* ✅ Insert DB */ if ($message == '') { $sql = "INSERT INTO vcard_testimonials (vcard_id, client_name, message, client_image, status, created_at) VALUES ('$vcard_id', '$client_name', '$msg', '$client_image', '$status', NOW())"; if (mysqli_query($conn, $sql)) { header("Location: vcard_testimonial_list.php?msg=Testimonial added successfully"); exit; } else { $message = "Database Error: " . mysqli_error($conn); } } } ?> <!-- ✅ Page Body --> <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 card-no-border"> <h2>Add VCard Testimonial</h2> </div> <div class="card-body"> <?php if ($message): ?> <div class="alert alert-danger"><?= htmlspecialchars($message); ?></div> <?php endif; ?> <form method="POST" enctype="multipart/form-data"> <div class="row"> <div class="col-md-6"> <label class="form-label">Select VCard *</label> <select name="vcard_id" class="form-control" required> <option value="">-- Select VCard --</option> <?php $vcards = mysqli_query( $conn, "SELECT id, full_name FROM vcards WHERE status=1 ORDER BY full_name" ); while ($v = mysqli_fetch_assoc($vcards)) { echo "<option value='{$v['id']}'>" . htmlspecialchars($v['full_name']) . "</option>"; } ?> </select> </div> <div class="col-md-6"> <label class="form-label">Client Name *</label> <input type="text" name="client_name" class="form-control" required> </div> <div class="col-md-12 mt-3"> <label class="form-label">Message</label> <textarea name="message" class="form-control" rows="4"></textarea> </div> <div class="col-md-6 mt-3"> <label class="form-label">Client Image</label> <input type="file" name="client_image" class="form-control"> </div> <div class="col-md-6 mt-3"> <label class="form-label">Status</label><br> <input type="checkbox" name="status" checked> Active </div> </div> <br> <div class="text-start"> <button type="submit" class="btn btn-success">Save Testimonial</button> <a href="vcard_testimonial_list.php" class="btn btn-secondary">Cancel</a> </div> </form> </div> </div> </div> </div> </div> </div> <?php include 'footer.php'; ob_end_flush(); ?>