hjkhjkjhkhjkgjghjhgjhgjghjhghjghjhgjjnbvnvbnvk
bnmbnmbnhjkhjkhjkhjktyutyutyuytutyutyutyhgjgjghjgjghjguytutyry
/
home
/
wjcvelqp
/
public_html
/
vc
/
Upload FileeE
HOME
<?php require_once __DIR__ . '/includes/bootstrap.php'; if (auth_check()) { redirect('dashboard/index.php'); } $errors = []; $old = []; if (is_post()) { csrf_require(); $old = $_POST; $full_name = clean_string($_POST['full_name'] ?? '', 150); $username = strtolower(clean_string($_POST['username'] ?? '', 80)); $email = strtolower(clean_string($_POST['email'] ?? '', 190)); $phone = clean_string($_POST['phone'] ?? '', 30); $password = (string) ($_POST['password'] ?? ''); $password2 = (string) ($_POST['password_confirm'] ?? ''); $account_type = clean_string($_POST['account_type'] ?? 'individual', 40); $state_id = (int) ($_POST['state_id'] ?? 0) ?: null; $lga_id = (int) ($_POST['lga_id'] ?? 0) ?: null; $terms = !empty($_POST['terms']); if ($full_name === '') $errors[] = 'Full name is required.'; if ($username === '' || !preg_match('/^[a-z0-9_]{3,30}$/', $username)) $errors[] = 'Username must be 3–30 characters (letters, numbers, underscore).'; if (!validate_email($email)) $errors[] = 'Valid email is required.'; if ($pw = validate_password($password)) $errors[] = $pw; if ($password !== $password2) $errors[] = 'Passwords do not match.'; if (!array_key_exists($account_type, nigeria_account_types())) $account_type = 'individual'; if (!$terms) $errors[] = 'You must accept the Terms and Community Guidelines.'; if (!$errors) { try { $st = db()->prepare('SELECT id FROM users WHERE email = ? OR username = ? LIMIT 1'); $st->execute([$email, $username]); if ($st->fetch()) { $errors[] = 'Email or username already registered.'; } else { $hash = password_hash($password, PASSWORD_DEFAULT); db()->prepare(" INSERT INTO users (full_name, username, email, phone, password_hash, account_type, state_id, lga_id, status, profile_completion, created_at) VALUES (?,?,?,?,?,?,?,?,'active',30,NOW()) ")->execute([$full_name, $username, $email, $phone, $hash, $account_type, $state_id, $lga_id]); $uid = (int) db()->lastInsertId(); $token = bin2hex(random_bytes(32)); db()->prepare('INSERT INTO email_verification_tokens (user_id, token, expires_at) VALUES (?,?, DATE_ADD(NOW(), INTERVAL ? HOUR))') ->execute([$uid, $token, VC_TOKEN_HOURS]); $verifyUrl = url('verify-email.php?token=' . $token); $mailErr = null; send_mail($email, 'Verify your VillageConnect account', mail_template( 'Verify your email', '<p>Hello ' . e($full_name) . ',</p><p>Please verify your email:</p><p><a href="' . e($verifyUrl) . '">' . e($verifyUrl) . '</a></p>' ), $mailErr); log_user_activity($uid, 'register', 'New registration'); flash('success', 'Account created. Please check your email to verify' . ($mailErr ? ' (email may need SMTP setup — you can still log in).' : '.') ); redirect('login.php'); } } catch (Throwable $e) { $errors[] = VC_DEBUG ? $e->getMessage() : 'Registration failed. Please try again.'; } } } $states = []; try { $states = db()->query('SELECT id, name FROM states ORDER BY name')->fetchAll(); } catch (Throwable $e) { } $page_title = 'Register — ' . VC_APP_NAME; $nav = ''; include __DIR__ . '/includes/header.php'; ?> <div class="auth-wrap"> <div class="container"> <div class="form-box"> <h1>Create account</h1> <p class="muted">Join VillageConnect Nigeria to list products, services, jobs and community projects.</p> <?php foreach ($errors as $err): ?><div class="alert alert-error"><?= e($err) ?></div><?php endforeach; ?> <form method="post" novalidate> <?= csrf_field() ?> <div class="form-group"><label>Full name <span class="req">*</span></label> <input type="text" name="full_name" required value="<?= e($old['full_name'] ?? '') ?>"></div> <div class="form-group"><label>Username <span class="req">*</span></label> <input type="text" name="username" required pattern="[a-zA-Z0-9_]{3,30}" value="<?= e($old['username'] ?? '') ?>"></div> <div class="form-group"><label>Email <span class="req">*</span></label> <input type="email" name="email" required value="<?= e($old['email'] ?? '') ?>"></div> <div class="form-group"><label>Phone</label> <input type="text" name="phone" value="<?= e($old['phone'] ?? '') ?>"></div> <div class="form-group"><label>Account type</label> <select name="account_type"> <?php foreach (nigeria_account_types() as $k => $label): ?> <option value="<?= e($k) ?>" <?= ($old['account_type'] ?? '') === $k ? 'selected' : '' ?>><?= e($label) ?></option> <?php endforeach; ?> </select> </div> <div class="form-group"><label>State</label> <select name="state_id" id="regState" data-lga-target="regLga"> <option value="">Select state</option> <?php foreach ($states as $s): ?> <option value="<?= (int)$s['id'] ?>" <?= ((int)($old['state_id'] ?? 0) === (int)$s['id']) ? 'selected' : '' ?>><?= e($s['name']) ?></option> <?php endforeach; ?> </select> </div> <div class="form-group"><label>LGA</label> <select name="lga_id" id="regLga"><option value="">Select LGA</option></select> </div> <div class="form-group"><label>Password <span class="req">*</span></label> <input type="password" name="password" id="regPass" required minlength="8"> <button type="button" class="btn btn-sm btn-outline" data-toggle-password="regPass" style="margin-top:6px">Show</button> </div> <div class="form-group"><label>Confirm password <span class="req">*</span></label> <input type="password" name="password_confirm" required minlength="8"></div> <label style="display:flex;gap:8px;align-items:flex-start;margin:12px 0;font-size:.9rem"> <input type="checkbox" name="terms" value="1" required style="margin-top:3px"> <span>I accept the <a href="<?= e(url('terms.php')) ?>" target="_blank">Terms</a> and <a href="<?= e(url('community-guidelines.php')) ?>" target="_blank">Community Guidelines</a>.</span> </label> <button class="btn btn-primary" type="submit" style="width:100%">Register</button> </form> <p style="margin-top:14px">Already have an account? <a href="<?= e(url('login.php')) ?>">Log in</a></p> </div> </div> </div> <?php include __DIR__ . '/includes/footer.php'; ?>