This commit is contained in:
Suvodip
2025-03-07 16:49:09 +05:30
parent a6522f589d
commit 881c48d5bb
13 changed files with 800 additions and 189 deletions

View File

@@ -6,48 +6,51 @@
<h4>Customer Registration</h4>
</div>
<div class="card-body">
<?php
require('../.hta_config/conf.php');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
$customerId = str_replace('.', '', uniqid('cust_', true));
$userPassword = md5($_POST['password']);
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
<?php
require('../.hta_config/conf.php');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
$customerId = str_replace('.', '', uniqid('cust_', true));
$userPassword = md5($_POST['password']);
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("INSERT INTO customers (name, mobile, email, customerId) VALUES (:name, :mobile, :email, :customerId)");
$stmt->bindParam(':name', $_POST['name']);
$stmt->bindParam(':mobile', $_POST['mobile']);
$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':customerId', $customerId);
$stmt = $db->prepare("INSERT INTO customers (name, mobile, email, customerId, company, address, sallery) VALUES (:name, :mobile, :email, :customerId, :company, :address, :sallery)");
$stmt->bindParam(':name', $_POST['name']);
$stmt->bindParam(':mobile', $_POST['mobile']);
$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':company', $_POST['jobCompany']);
$stmt->bindParam(':address', $_POST['billingAddress']);
$stmt->bindParam(':sallery', $_POST['sallery']);
$stmt->bindParam(':customerId', $customerId);
$stmt2 = $db->prepare("INSERT INTO users (name, mobile, email, type, password, customerId) VALUES (:name, :mobile, :email, :type, :password, :customerId)");
$stmt2->bindParam(':name', $_POST['name']);
$stmt2->bindParam(':mobile', $_POST['mobile']);
$stmt2->bindParam(':email', $_POST['email']);
$stmt2->bindParam(':type', $_POST['type']);
$stmt2->bindParam(':password', $userPassword);
$stmt2->bindParam(':customerId', $customerId);
$stmt2 = $db->prepare("INSERT INTO users (name, mobile, email, type, password, customerId) VALUES (:name, :mobile, :email, :type, :password, :customerId)");
$stmt2->bindParam(':name', $_POST['name']);
$stmt2->bindParam(':mobile', $_POST['mobile']);
$stmt2->bindParam(':email', $_POST['email']);
$stmt2->bindParam(':type', $_POST['type']);
$stmt2->bindParam(':password', $userPassword);
$stmt2->bindParam(':customerId', $customerId);
if ($stmt->execute()) {
$stmt2->execute();
echo '<div class="alert alert-success">New Customer <strong>' . htmlspecialchars($_POST['name']) . '</strong> created successfully.</div>';
} else {
echo '<div class="alert alert-danger">Error inserting into customers table: ' . $stmt->errorInfo()[2] . '</div>';
if ($stmt->execute()) {
$stmt2->execute();
echo '<div class="alert alert-success">New Customer <strong>' . htmlspecialchars($_POST['name']) . '</strong> created successfully.</div>';
} else {
echo '<div class="alert alert-danger">Error inserting into customers table: ' . $stmt->errorInfo()[2] . '</div>';
}
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
}
?>
<form method="POST">
<div class="form-group">
<label for="name">Name:</label>
<label for="name">Full Name:</label>
<input type="text" id="name" name="name" class="form-control" required>
</div>
<div class="form-group">
<label for="mobile">Mobile:</label>
<label for="mobile">Contact:</label>
<input type="text" id="mobile" name="mobile" class="form-control" required>
</div>
@@ -56,6 +59,21 @@
<input type="email" id="email" name="email" class="form-control" required>
</div>
<div class="form-group">
<label for="jobCompany">Company:</label>
<input type="text" id="jobCompany" name="jobCompany" class="form-control" required>
</div>
<div class="form-group">
<label for="billingAddress">Billing Address:</label>
<input type="text" id="billingAddress" name="billingAddress" class="form-control" required>
</div>
<div class="form-group">
<label for="sallery">Sallery He Recieved:</label>
<input type="text" id="sallery" name="sallery" class="form-control" required>
</div>
<div class="form-group">
<label for="type">User Type:</label>
<select class="form-control" name="type" id="type" require>