first commit
This commit is contained in:
51
customers/.hta_slug/new.php
Normal file
51
customers/.hta_slug/new.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card shadow-lg">
|
||||
<div class="card-header bg-primary text-white text-center">
|
||||
<h4>Customer Registration</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php
|
||||
require('../.hta_config/conf.php');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
try {
|
||||
$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) VALUES (:name, :mobile, :email)");
|
||||
$stmt->bindParam(':name', $_POST['name']);
|
||||
$stmt->bindParam(':mobile', $_POST['mobile']);
|
||||
$stmt->bindParam(':email', $_POST['email']);
|
||||
|
||||
if ($stmt->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 executing statement: ' . $stmt->errorInfo()[2] . '</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>
|
||||
<input type="text" id="name" name="name" class="form-control" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="mobile">Mobile:</label>
|
||||
<input type="text" id="mobile" name="mobile" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="email">Email:</label>
|
||||
<input type="email" id="email" name="email" class="form-control" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success btn-block mt-2">Save Customer</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user