140 lines
7.0 KiB
PHP
140 lines
7.0 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
$message = null;
|
|
$message_type = '';
|
|
|
|
// Idempotent table creation
|
|
try {
|
|
$pdo = db();
|
|
$pdo->exec("CREATE TABLE IF NOT EXISTS vendors (id INT AUTO_INCREMENT PRIMARY KEY, business_name VARCHAR(255) NOT NULL, contact_name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL UNIQUE, phone VARCHAR(50), status VARCHAR(50) DEFAULT 'pending_approval', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)");
|
|
} catch (PDOException $e) {
|
|
// In a real app, log this error. For now, we'll just ignore if it fails.
|
|
}
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
$business_name = trim($_POST['business_name'] ?? '');
|
|
$contact_name = trim($_POST['contact_name'] ?? '');
|
|
$email = trim($_POST['email'] ?? '');
|
|
$phone = trim($_POST['phone'] ?? '');
|
|
|
|
if (empty($business_name) || empty($contact_name) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
$message = "Error: Please fill all required fields with valid data.";
|
|
$message_type = 'danger';
|
|
} else {
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("INSERT INTO vendors (business_name, contact_name, email, phone) VALUES (?, ?, ?, ?)");
|
|
$stmt->execute([$business_name, $contact_name, $email, $phone]);
|
|
$message = "Thank you! Your application has been submitted for review.";
|
|
$message_type = 'success';
|
|
} catch (PDOException $e) {
|
|
if ($e->errorInfo[1] == 1062) { // Duplicate entry
|
|
$message = "Error: An account with this email address already exists.";
|
|
} else {
|
|
$message = "An unexpected error occurred. Please try again later.";
|
|
}
|
|
$message_type = 'danger';
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Vendor Onboarding - MVNOLocationBasedOffer</title>
|
|
<meta name="description" content="Built with Flatlogic Generator. Onboard your business to start offering location-based deals.">
|
|
<meta name="keywords" content="vendor onboarding, location offers, business registration, mvno, daily deals, local marketing, Built with Flatlogic Generator">
|
|
<meta property="og:title" content="Vendor Onboarding - MVNOLocationBasedOffer">
|
|
<meta property="og:description" content="Join our platform to connect with customers through location-based offers.">
|
|
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '', ENT_QUOTES, 'UTF-8'); ?>">
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
<meta name="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '', ENT_QUOTES, 'UTF-8'); ?>">
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
|
|
<?php if ($message): ?>
|
|
<div class="toast-container position-fixed top-0 end-0 p-3">
|
|
<div class="toast align-items-center text-white bg-<?php echo $message_type; ?> border-0" role="alert" aria-live="assertive" aria-atomic="true">
|
|
<div class="d-flex">
|
|
<div class="toast-body">
|
|
<?php echo htmlspecialchars($message); ?>
|
|
</div>
|
|
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="index.php">MVNO Offers</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav ms-auto">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="index.php">Home</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link active" aria-current="page" href="vendor-onboarding.php">For Vendors</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="container my-5">
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-7 col-md-9">
|
|
<div class="card p-4 p-md-5">
|
|
<div class="text-center mb-4">
|
|
<h1 class="h2">Become a Partner</h1>
|
|
<p class="text-muted">Join our network to reach more customers. Fill out the form below to get started.</p>
|
|
</div>
|
|
<form id="vendorOnboardingForm" action="vendor-onboarding.php" method="POST" novalidate>
|
|
<div class="mb-3">
|
|
<label for="business_name" class="form-label">Business Name</label>
|
|
<input type="text" class="form-control" id="business_name" name="business_name" required>
|
|
<div class="invalid-feedback">Please enter your business name.</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="contact_name" class="form-label">Contact Name</label>
|
|
<input type="text" class="form-control" id="contact_name" name="contact_name" required>
|
|
<div class="invalid-feedback">Please enter a contact name.</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="email" class="form-label">Email Address</label>
|
|
<input type="email" class="form-control" id="email" name="email" required>
|
|
<div class="invalid-feedback">Please enter a valid email address.</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="phone" class="form-label">Phone Number (Optional)</label>
|
|
<input type="tel" class="form-control" id="phone" name="phone">
|
|
</div>
|
|
<div class="d-grid mt-4">
|
|
<button type="submit" class="btn btn-primary btn-lg">Submit Application</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<footer class="text-center py-4 text-muted border-top">
|
|
<div class="container">
|
|
© <?php echo date("Y"); ?> MVNOLocationBasedOffer. All Rights Reserved.
|
|
</div>
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
|
</body>
|
|
</html>
|