| Server IP : 103.243.232.44 / Your IP : 216.73.216.250 Web Server : LiteSpeed System : Linux server17213-10344.hostycare.online 5.14.0-687.38.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 12 17:19:12 EDT 2026 x86_64 User : iamakash ( 1400) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/iamakash/public_html/shaurya.meals28.com/ |
Upload File : |
<?php
require __DIR__ . '/includes/auth.php';
// Already logged in → go to dashboard
if (isLoggedIn()) {
header('Location: ' . base_url('index.php'));
exit;
}
$errors = [];
$values = ['first_name'=>'','last_name'=>'','email'=>'','mobile'=>'','city'=>'','state'=>'','password'=>'','confirm_password'=>''];
$success = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$values['first_name'] = trim($_POST['first_name'] ?? '');
$values['last_name'] = trim($_POST['last_name'] ?? '');
$values['email'] = trim($_POST['email'] ?? '');
$values['mobile'] = trim($_POST['mobile'] ?? '');
$values['city'] = trim($_POST['city'] ?? '');
$values['state'] = trim($_POST['state'] ?? '');
$values['password'] = $_POST['password'] ?? '';
$values['confirm_password'] = $_POST['confirm_password'] ?? '';
// Validate
if ($values['first_name'] === '') $errors['first_name'] = 'First name is required.';
if ($values['email'] === '') {
$errors['email'] = 'Email is required.';
} elseif (!filter_var($values['email'], FILTER_VALIDATE_EMAIL)) {
$errors['email'] = 'Enter a valid email address.';
}
if ($values['mobile'] === '') {
$errors['mobile'] = 'Mobile number is required.';
} elseif (!preg_match('/^[6-9]\d{9}$/', $values['mobile'])) {
$errors['mobile'] = 'Enter a valid 10-digit Indian mobile number.';
}
if ($values['city'] === '') $errors['city'] = 'City is required.';
if ($values['state'] === '') $errors['state'] = 'State is required.';
if ($values['password'] === '') {
$errors['password'] = 'Password is required.';
} elseif (strlen($values['password']) < 6) {
$errors['password'] = 'Password must be at least 6 characters.';
}
if ($values['confirm_password'] === '') {
$errors['confirm_password'] = 'Please confirm your password.';
} elseif ($values['password'] !== $values['confirm_password']) {
$errors['confirm_password'] = 'Passwords do not match.';
}
// Check uniqueness if no validation errors so far
if (empty($errors)) {
$pdo = getPDO();
$stmt = $pdo->prepare('SELECT id FROM users WHERE email = ? LIMIT 1');
$stmt->execute([$values['email']]);
if ($stmt->fetch()) {
$errors['email'] = 'This email is already registered.';
}
$stmt = $pdo->prepare('SELECT id FROM users WHERE mobile = ? LIMIT 1');
$stmt->execute([$values['mobile']]);
if ($stmt->fetch()) {
$errors['mobile'] = 'This mobile number is already registered.';
}
}
// Insert
if (empty($errors)) {
$pdo = getPDO();
$hash = password_hash($values['password'], PASSWORD_BCRYPT);
$stmt = $pdo->prepare(
'INSERT INTO users (first_name, last_name, email, mobile, city, state, password_hash)
VALUES (?, ?, ?, ?, ?, ?, ?)'
);
$stmt->execute([
$values['first_name'],
$values['last_name'],
$values['email'],
$values['mobile'],
$values['city'],
$values['state'],
$hash,
]);
$success = true;
}
}
$pageTitle = 'Create Account — Shaurya';
?><!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= h($pageTitle) ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body { background: #f6f7fb; }
.auth-card { max-width: 520px; margin: 3rem auto; }
.brand-header { background: #0d6efd; color: #fff; padding: 1.25rem 1.5rem; border-radius: .5rem .5rem 0 0; }
</style>
</head>
<body>
<div class="auth-card">
<div class="brand-header">
<h4 class="mb-0 fw-semibold">Shaurya · Index Factor</h4>
<div class="small opacity-75">Create a new account</div>
</div>
<div class="card" style="border-radius: 0 0 .5rem .5rem;">
<div class="card-body p-4">
<?php if ($success): ?>
<div class="alert alert-success">
Account created successfully! <a href="<?= base_url('login.php') ?>">Sign in now</a>.
</div>
<?php else: ?>
<?php if ($errors): ?>
<div class="alert alert-danger py-2 small">Please fix the errors below.</div>
<?php endif; ?>
<form method="post" novalidate>
<div class="row g-3">
<div class="col-sm-6">
<label class="form-label" for="first_name">First Name</label>
<input type="text" class="form-control <?= isset($errors['first_name']) ? 'is-invalid' : '' ?>"
id="first_name" name="first_name" autocomplete="given-name"
value="<?= h($values['first_name']) ?>" required autofocus>
<?php if (isset($errors['first_name'])): ?>
<div class="invalid-feedback"><?= h($errors['first_name']) ?></div>
<?php endif; ?>
</div>
<div class="col-sm-6">
<label class="form-label" for="last_name">Last Name</label>
<input type="text" class="form-control <?= isset($errors['last_name']) ? 'is-invalid' : '' ?>"
id="last_name" name="last_name" autocomplete="family-name"
value="<?= h($values['last_name']) ?>">
<?php if (isset($errors['last_name'])): ?>
<div class="invalid-feedback"><?= h($errors['last_name']) ?></div>
<?php endif; ?>
</div>
<div class="col-sm-6">
<label class="form-label" for="email">Email Address</label>
<input type="email" class="form-control <?= isset($errors['email']) ? 'is-invalid' : '' ?>"
id="email" name="email" autocomplete="username"
value="<?= h($values['email']) ?>" required>
<?php if (isset($errors['email'])): ?>
<div class="invalid-feedback"><?= h($errors['email']) ?></div>
<?php endif; ?>
</div>
<div class="col-sm-6">
<label class="form-label" for="mobile">Mobile Number</label>
<input type="tel" class="form-control <?= isset($errors['mobile']) ? 'is-invalid' : '' ?>"
id="mobile" name="mobile" autocomplete="tel"
value="<?= h($values['mobile']) ?>" required placeholder="10-digit">
<?php if (isset($errors['mobile'])): ?>
<div class="invalid-feedback"><?= h($errors['mobile']) ?></div>
<?php endif; ?>
</div>
<div class="col-sm-6">
<label class="form-label" for="city">City</label>
<input type="text" class="form-control <?= isset($errors['city']) ? 'is-invalid' : '' ?>"
id="city" name="city" autocomplete="address-level2"
value="<?= h($values['city']) ?>" required>
<?php if (isset($errors['city'])): ?>
<div class="invalid-feedback"><?= h($errors['city']) ?></div>
<?php endif; ?>
</div>
<div class="col-sm-6">
<label class="form-label" for="state">State</label>
<select class="form-select <?= isset($errors['state']) ? 'is-invalid' : '' ?>"
id="state" name="state" autocomplete="address-level1" required>
<option value="">— Select State —</option>
<?php
$states = [
'Andhra Pradesh','Arunachal Pradesh','Assam','Bihar','Chhattisgarh',
'Goa','Gujarat','Haryana','Himachal Pradesh','Jharkhand','Karnataka',
'Kerala','Madhya Pradesh','Maharashtra','Manipur','Meghalaya','Mizoram',
'Nagaland','Odisha','Punjab','Rajasthan','Sikkim','Tamil Nadu','Telangana',
'Tripura','Uttar Pradesh','Uttarakhand','West Bengal',
'Andaman and Nicobar Islands','Chandigarh','Dadra and Nagar Haveli and Daman and Diu',
'Delhi','Jammu and Kashmir','Ladakh','Lakshadweep','Puducherry',
];
foreach ($states as $s):
?>
<option value="<?= h($s) ?>" <?= $values['state'] === $s ? 'selected' : '' ?>><?= h($s) ?></option>
<?php endforeach; ?>
</select>
<?php if (isset($errors['state'])): ?>
<div class="invalid-feedback"><?= h($errors['state']) ?></div>
<?php endif; ?>
</div>
<div class="col-sm-6">
<label class="form-label" for="password">Password</label>
<input type="password" class="form-control <?= isset($errors['password']) ? 'is-invalid' : '' ?>"
id="password" name="password" autocomplete="new-password" required>
<?php if (isset($errors['password'])): ?>
<div class="invalid-feedback"><?= h($errors['password']) ?></div>
<?php endif; ?>
</div>
<div class="col-sm-6">
<label class="form-label" for="confirm_password">Confirm Password</label>
<input type="password" class="form-control <?= isset($errors['confirm_password']) ? 'is-invalid' : '' ?>"
id="confirm_password" name="confirm_password" autocomplete="new-password" required>
<?php if (isset($errors['confirm_password'])): ?>
<div class="invalid-feedback"><?= h($errors['confirm_password']) ?></div>
<?php endif; ?>
</div>
<div class="col-12 mt-2">
<button type="submit" class="btn btn-primary w-100">Create Account</button>
</div>
</div>
</form>
<?php endif; ?>
<p class="text-center text-muted small mt-3 mb-0">
Already have an account? <a href="<?= base_url('login.php') ?>">Sign in</a>
</p>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>