diff options
author | Saumit Dinesan <justsaumit@protonmail.com> | 2023-10-02 21:33:19 +0530 |
---|---|---|
committer | Saumit Dinesan <justsaumit@protonmail.com> | 2023-10-02 21:33:19 +0530 |
commit | abcb2c27dedf8dff976d002a521c725746dace42 (patch) | |
tree | 28963c30b39fc95cb0ae0748d20c9ca3302ac809 | |
parent | fa0fed060e5cb9a2ef365a60a24a576282a86016 (diff) |
Lab04: Properly formatting index.html and insert.php
-rw-r--r-- | Lab04/index.html | 2 | ||||
-rw-r--r-- | Lab04/insert.php | 60 |
2 files changed, 31 insertions, 31 deletions
diff --git a/Lab04/index.html b/Lab04/index.html index f433526..d633b82 100644 --- a/Lab04/index.html +++ b/Lab04/index.html @@ -42,4 +42,4 @@ <input type="submit" value="Submit">
</form>
</body>
-</html>
\ No newline at end of file +</html>
diff --git a/Lab04/insert.php b/Lab04/insert.php index 6a5a04f..717842e 100644 --- a/Lab04/insert.php +++ b/Lab04/insert.php @@ -14,40 +14,40 @@ $dbname = "regformdata";
$tablename = "regtable";
-// Create connection
-$conn = mysqli_connect($servername, $username, $password, $dbname);
+ // Create connection
+ $conn = mysqli_connect($servername, $username, $password, $dbname);
-// Check connection
-if ($conn === false) {
- die("Connection failed: "
- . mysqli_connect_error());
-}
+ // 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'];
+ $first_name = $_REQUEST['fname'];
+ $last_name = $_REQUEST['lname'];
+ $gender = $_REQUEST['gender'];
+ $phone = $_REQUEST['phone'];
+ $email = $_REQUEST['email'];
+ $city = $_REQUEST['city'];
+ $department = $_REQUEST['department'];
+
+ $sql = "INSERT INTO $tablename (fname, lname, gender, phone, email, city, department)
+ VALUES ('$first_name', '$last_name', '$gender', '$phone', '$email', '$city', '$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>";
+ 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);
+ }
- 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);
-?>
+ // Close connection
+ mysqli_close($conn);
+ ?>
</center>
</body>
|