-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandleForm.php
More file actions
35 lines (28 loc) · 857 Bytes
/
Copy pathHandleForm.php
File metadata and controls
35 lines (28 loc) · 857 Bytes
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
<HTML><HEAD><TITLE>HTML Form </TITLE></HEAD>
<BODY>
<?php
echo "Your name is". $_POST["Name"];
echo "Your ID is". $_POST["ID"];
include 'db_conn_test.php';
$conn = OpenCon();
echo "Connected Successfully";
$stmt = $conn->prepare("INSERT INTO sample (ID,Name) VALUES (?, ?)");
$stmt->bind_param("is",$_POST["ID"],$_POST["Name"]);
;
if ($stmt->execute() === TRUE) {
echo "New record created successfully";
} else {
echo "Error";
}
$sql = "SELECT * FROM sample";
$result = $conn->query($sql) or die($conn->error);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "ID: " . $row["ID"]. " - Name: " . $row["Name"]. "<br>";
}
} else {
echo "0 results";
}
?>
</BODY> </HTML>