-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.1.1 Apply_Credit_Card1.php
43 lines (34 loc) · 1.3 KB
/
3.1.1 Apply_Credit_Card1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "virtual_bank";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Form submission handling
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Escape user inputs for security
$name = $conn->real_escape_string($_POST['name']);
$phone = $conn->real_escape_string($_POST['phone']);
$email = $conn->real_escape_string($_POST['email']);
// Check if 'types' index is set in $_POST array
$types = isset($_POST['types']) ? $conn->real_escape_string($_POST['types']) : '';
$pan = $conn->real_escape_string($_POST['pan']);
$address = $conn->real_escape_string($_POST['address']);
$pin = $conn->real_escape_string($_POST['pin']);
// Insert data into database
$sql = "INSERT INTO apply_credit (name, phone, email, types, pan, address, pin)
VALUES ('$name', '$phone', '$email', '$types', '$pan', '$address', '$pin')";
if ($conn->query($sql) === TRUE) {
echo "Credit card applied successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
// Close connection
$conn->close();
?>