require __DIR__.'/../app/bootstrap.php'; require __DIR__.'/../app/layout.php'; if (current_user()) { redirect('/member/dashboard.php'); } if ($_SERVER['REQUEST_METHOD'] === 'POST') { csrf_check(); $name = post_string('name'); $email = strtolower(post_string('email')); $mobile = preg_replace('/\D+/', '', post_string('mobile')); $password = (string)($_POST['password'] ?? ''); $ref = strtoupper(post_string('referral_code') ?: (string)($_GET['ref'] ?? '')); if (mb_strlen($name) < 2 || !filter_var($email, FILTER_VALIDATE_EMAIL) || !preg_match('/^[0-9]{10}$/', $mobile) || strlen($password) < 8) { flash('error', 'Enter valid name, email, 10-digit mobile and a password of at least 8 characters.'); redirect('/auth/register.php'); } $pdo = db(); try { $ex = $pdo->prepare("SELECT u.id,u.status,mp.payment_no,mp.status payment_status FROM users u LEFT JOIN membership_payments mp ON mp.user_id=u.id AND mp.status IN ('pending','failed') WHERE u.email=? ORDER BY mp.id DESC LIMIT 1"); $ex->execute([$email]); $existing = $ex->fetch(); if ($existing) { if (($existing['status'] ?? '') === 'pending' && !empty($existing['payment_no'])) { redirect('/auth/membership-payment.php?payment=' . urlencode((string)$existing['payment_no'])); } throw new RuntimeException('An account with this email already exists. Please use Member Login or Forgot Password.'); } $referrer = null; if ($ref !== '') { $q = $pdo->prepare("SELECT id FROM users WHERE referral_code=? AND role='member' LIMIT 1"); $q->execute([$ref]); $referrer = (int)($q->fetchColumn() ?: 0); if (!$referrer) { throw new RuntimeException('Referral code was not found.'); } } $method = selected_payment_method('membership'); if (!$method) { throw new RuntimeException('Membership payment is temporarily unavailable. Please contact support.'); } $pdo->beginTransaction(); $member = 'KAN' . date('ymd') . strtoupper(bin2hex(random_bytes(3))); $rcode = strtoupper(substr(str_replace(['0', 'O', 'I', '1'], ['A', 'B', 'C', 'D'], bin2hex(random_bytes(6))), 0, 10)); $q = $pdo->prepare("INSERT INTO users(member_code,name,email,mobile,password_hash,role,status,kyc_status,referral_code,referred_by) VALUES(?,?,?,?,?,'member','pending','not_started',?,?)"); $q->execute([$member, $name, $email, $mobile, password_hash($password, PASSWORD_DEFAULT), $rcode, $referrer ?: null]); $uid = (int)$pdo->lastInsertId(); $pno = random_code('MEM'); $q = $pdo->prepare("INSERT INTO membership_payments(payment_no,user_id,amount,payment_method,status) VALUES(?,?,?,?,?)"); $q->execute([$pno, $uid, 1599, $method['method'], 'pending']); $pdo->commit(); audit('membership_registration_created', $uid, ['payment_no' => $pno, 'payment_method' => $method['method']]); EmailService::accountEvent( $config, ['id' => $uid, 'email' => $email], 'registration', 'KANIXO registration received', "Hello {$name},\n\nYour KANIXO member account has been created successfully.\nMember ID: {$member}\nRegistration status: Pending membership payment.\nMembership amount: ₹1,599\n\nPlease complete the membership payment to activate your account.\nPayment reference: {$pno}" ); redirect('/auth/membership-payment.php?payment=' . urlencode($pno)); } catch (Throwable $e) { if ($pdo->inTransaction()) { $pdo->rollBack(); } flash('error', $e->getMessage()); redirect('/auth/register.php'); } } /* * Inject Open Graph/Twitter metadata into the document head so WhatsApp, * Facebook and other crawlers can render a branded referral preview. */ $kx_ref = strtoupper(trim((string)($_GET['ref'] ?? ''))); $kx_share_url = base_url('/auth/register.php' . ($kx_ref !== '' ? '?ref=' . rawurlencode($kx_ref) : '')); $kx_image_url = base_url('/auth/register.php?og_image=1'); $kx_meta = '' . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n"; ob_start(); layout_header('Join KANIXO'); $kx_header_html = (string)ob_get_clean(); if (stripos($kx_header_html, '') !== false) { $kx_header_html = preg_replace('/<\/head>/i', $kx_meta . '', $kx_header_html, 1); } echo $kx_header_html; ?>
Create your member account and access your KANIXO workspace, business tools, order activity and member support.
Enter your details below to create your member account. Your membership payment will be completed in the next step.