summaryrefslogtreecommitdiff
path: root/Lab04/insert.php
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-09-13 19:08:54 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-09-13 19:08:54 +0530
commit08dc058cfe1184281fef89c0c484b9e8a6b7a6b7 (patch)
tree834158194e039ef4a76a30752241089f06c87be7 /Lab04/insert.php
parentf8a237e363b020e876f553520329046cf813da8e (diff)
Lab04: HTML Form Validation + Factorial
Diffstat (limited to 'Lab04/insert.php')
-rw-r--r--Lab04/insert.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/Lab04/insert.php b/Lab04/insert.php
new file mode 100644
index 0000000..6a5a04f
--- /dev/null
+++ b/Lab04/insert.php
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <title>Insert Page page</title>
+</head>
+
+<body>
+ <center>
+ <?php
+ $servername = "db";
+ $username = "example";
+ $password = "example";
+ $dbname = "regformdata";
+ $tablename = "regtable";
+
+// Create connection
+$conn = mysqli_connect($servername, $username, $password, $dbname);
+
+// Check connection
+if ($conn === false) {
+ die("Connection failed: "
+ . mysqli_connect_error());
+}
+
+$first_name = $_REQUEST['fname'];
+$last_name = $_REQUEST['lname'];
+$gender = $_REQUEST['gender'];
+$phone = $_REQUEST['phone'];
+$email = $_REQUEST['email'];
+$city = $_REQUEST['city'];
+$department = $_REQUEST['department'];
+
+$sql2 = "INSERT INTO regform VALUES (first_name, last_name, gender, phone, email, city, department)";
+if(mysqli_query($conn, $sql)){
+ echo "<h3>Data stored in a database successfully."
+ . " Please browse your localhost php my admin"
+ . " to view the updated data</h3>";
+
+ echo nl2br("\n$first_name\n $last_name\n "
+ . "$gender\n $phone \n $email \n $city\n $department");
+
+} else{
+ echo "ERROR: Could not insert the data values $sql. "
+ . mysqli_error($conn);
+}
+
+// Close connection
+mysqli_close($conn);
+?>
+ </center>
+</body>
+
+</html> \ No newline at end of file