<?php require __DIR__.'/../lib/bootstrap.php'; if($_SERVER['REQUEST_METHOD']==='POST'){if(!verify_csrf())$error='Your session expired.';else{$role=$_POST['role']==='provider'?'provider':'business';$email=strtolower(trim($_POST['email']));if(!filter_var($email,FILTER_VALIDATE_EMAIL))$error='Enter a valid email.';elseif(strlen($_POST['password'])<8)$error='Password must contain at least 8 characters.';elseif(db_one('SELECT id FROM users WHERE email=?',array($email)))$error='An account already exists.';else{$status=$role==='provider'?'pending':'active';db_exec('INSERT INTO users(name,email,password_hash,role,status,created_at) VALUES(?,?,?,?,?,NOW())',array(trim($_POST['name']),$email,password_hash($_POST['password'],PASSWORD_DEFAULT),$role,$status));flash('success',$role==='provider'?'Application received. An administrator will review your provider account.':'Account created. Please log in.');redirect('auth/login.php');}}}$type=isset($_GET['type'])?$_GET['type']:'business';$pageTitle='Create Account';require __DIR__.'/../blocks/app-header.php';?><section class="container"><div class="card form-card" style="margin:auto"><div class="eyebrow">JOIN FUNDZ</div><h2>Create your account</h2><?php if(isset($error)):?><div class="flash danger"><?=e($error)?></div><?php endif;?><form method="post"><?=csrf_field()?><div class="form-group"><label>Account type</label><select class="form-control" name="role"><option value="business" <?=$type==='business'?'selected':''?>>Business</option><option value="provider" <?=$type==='provider'?'selected':''?>>Verified provider applicant</option></select></div><div class="form-group"><label>Name or company</label><input class="form-control" name="name" required></div><div class="form-group"><label>Email</label><input class="form-control" type="email" name="email" required></div><div class="form-group"><label>Password</label><input class="form-control" type="password" name="password" minlength="8" required></div><button class="orange-btn" type="submit">Create account</button></form></div></section><?php require __DIR__.'/../blocks/app-footer.php';?>