Create New Item
×
Item Type
File
Folder
Item Name
×
Search file in folder and subfolders...
File Manager
/
fsib
/
accountOpening-v2
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<!-- <!DOCTYPE html> <html> <head> <title>New Branch Create</title> </head> <body> <h1>New Branch Create</h1> <form id="branchForm" method="post"> <label for="zone">Select Zone:</label> <select name="zone" id="zone"> <option value="">Select a Zone</option> <option value="zone1">Zone 1</option> <option value="zone2">Zone 2</option> <option value="zone3">Zone 3</option> </select> <br><br> <label for="branchCode">Branch Code:</label> <input type="text" id="branchCode" name="branchCode"> <br><br> <label for="branchName">Branch Name:</label> <input type="text" id="branchName" name="branchName"> <br><br> <input type="submit" name="submit" value="Submit"> </form> <script> document.getElementById('branchForm').addEventListener('submit', function(event) { event.preventDefault(); var zone = document.getElementById('zone').value; var branchCode = document.getElementById('branchCode').value; var branchName = document.getElementById('branchName').value; alert('New branch created successfully!\nZone: ' + zone + '\nBranch Code: ' + branchCode + '\nBranch Name: ' + branchName); }); </script> </body> </html> --> <?php $servername = "localhost"; $username = "root"; $password = ""; $database = "fsibplc_account_opening"; // Create connection $conn = new mysqli($servername, $username, $password, $database); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $success = false; // Check if the form was submitted if ($_SERVER["REQUEST_METHOD"] == "POST") { // Retrieve the form data $zone = $_POST["zone"]; $branchCode = $_POST["branchCode"]; $branchName = $_POST["branchName"]; // Insert data into the 'branch' table $sql1 = "INSERT INTO branch (zone_id, branch_id, branch_name) VALUES (?, ?, ?)"; $stmt1 = $conn->prepare($sql1); $stmt1->bind_param("iss", $zone, $branchCode, $branchName); if ($stmt1->execute()) { // Insert data into the 'branch_div_details' table $sql2 = "INSERT INTO branch_div_details (branch_name, branch_code, zone) VALUES (?, ?, ?)"; $stmt2 = $conn->prepare($sql2); $stmt2->bind_param("sss", $branchName, $branchCode, $zone); if ($stmt2->execute()) { $success = true; } } } ?> <!DOCTYPE html> <html> <head> <title>New Branch Create</title> <script> <?php if ($success) { ?> alert('New branch created successfully!\nZone: <?php echo $zone; ?>\nBranch Code: <?php echo $branchCode; ?>\nBranch Name: <?php echo $branchName; ?>'); <?php } ?> </script> </head> <body> <h1>New Branch Create</h1> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <label for="zone">Select Zone:</label> <select name="zone" id="zone"> <option value="">Select a Zone</option> <option value="zone1">Zone 1</option> <option value="zone2">Zone 2</option> <option value="zone3">Zone 3</option> </select> <br><br> <label for="branchCode">Branch Code:</label> <input type="text" id="branchCode" name="branchCode"> <br><br> <label for="branchName">Branch Name:</label> <input type="text" id="branchName" name="branchName"> <br><br> <input type="submit" name="submit" value="Submit"> </form> </body> </html>