Customer Registration

setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $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); if ($stmt->execute()) { $stmt2->execute(); echo '
New Customer ' . htmlspecialchars($_POST['name']) . ' created successfully.
'; } else { echo '
Error inserting into customers table: ' . $stmt->errorInfo()[2] . '
'; } } catch (PDOException $e) { echo '
Error: ' . $e->getMessage() . '
'; } } ?>