Skip to content

Commit

Permalink
Update WEB lab assignments and fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
sthsuyash committed Jan 13, 2024
1 parent b1e5503 commit b93f943
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<body>

<script>
var jsonString = '{"name": "John Doe", "age": 30, "city": "New York", "skills": ["JavaScript", "HTML", "CSS"]}';
var jsonString = '{"name": "Suyash Shrestha", "age": 21, "city": "KTM", "skills": ["JavaScript", "HTML", "CSS"]}';
var parsedData = JSON.parse(jsonString);

document.write("<p>Name: " + parsedData.name + "</br>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
this.year = year;
}

document.write('<h1>Person</h1>');
document.write('Name: ' + person.name + '</br>');
document.write('Age: ' + person.age + '</br>');
document.write('Gender: ' + person.gender + '</p>');
console.log('Person Object: ');
console.log('Name: ' + person.name);
console.log('Age: ' + person.age);
console.log('Gender' + person.gender);

var myCar = new Car('Toyota', 'Camry', 2022);
document.write('<h1>Car</h1>');
document.write('<p>Make: ' + myCar.make + '</br>');
document.write('Model: ' + myCar.model + '</p>');
console.log(myCar);
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Lab Assignment – V (JavaScript and XML)
# Lab Assignment – III (JavaScript and XML)

1. Illustrate with examples the concept of alert, confirm and popup boxes • [Code](1_alert_confirm_popup.html)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php
include "1_connection.php";
$id = $_GET["id"];
$sql = "SELECT * FROM first_semester WHERE id='$id'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$id = $_GET["id"];
// Validate and sanitize input data
$name = filter_var($_POST["name"], FILTER_SANITIZE_STRING);
$email = filter_var($_POST["email"], FILTER_VALIDATE_EMAIL);
Expand All @@ -11,7 +14,7 @@
if ($name && $email) {
$sql = "UPDATE first_semester SET name='$name', email='$email' WHERE id='$id'";
if (mysqli_query($conn, $sql)) {
echo "Record inserted successfully!";
echo "Record updated successfully!";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
Expand All @@ -31,8 +34,8 @@

<body>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<input type="text" name="name" placeholder="Name">
<input type="text" name="email" placeholder="Email">
<input type="text" name="name" value="<?php echo $row["name"]; ?>">
<input type="text" name="email" value="<?php echo $row["email"]; ?>">
<input type="submit" value="Submit">
</form>
</body>
Expand Down
46 changes: 30 additions & 16 deletions 5th_Semester/Web_Technology/Lab4 (PHP)/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
# Lab Assignment – IV (PHP)

1. Write a simple PHP script that prints "Hello, PHP!" to the browser.
2. Declare variables of different data types (integer, float, string) and demonstrate the usage of constants in PHP.
3. Create a PHP program that uses if-else statements to check if a number is positive, negative, or zero. Utilize different operators for comparison.
4. Develop a function that calculates the average of an array of numbers. Test the function with various arrays.
5. Define a PHP class representing a "Book" with properties like title and author. Create objects of this class and display their attributes.
6. Design a simple HTML form with input fields. Create a PHP script that retrieves and displays the form data when submitted.
7. Enhance the previous form with PHP validation. Ensure that required fields are filled, and validate email addresses and make sure the phone number starts with 98 or 97 using regex
8. Implement PHP code that responds to a button click event on a form. Display a message when the button is clicked.
9. Create a PHP script that sets a cookie with user preferences.Retrieve and display this information on subsequent visits.
10. Build a form with various elements (textboxes, checkboxes, radio buttons). Use PHP to access and display the selected values.
11. Develop a PHP script that reads content from a text file, modifies it, and then writes the updated content back to the file.
1. Write a simple PHP script that prints "Hello, PHP!" to the browser • [Code](1_hello_php.php)

2. Declare variables of different data types (integer, float, string) and demonstrate the usage of constants in PHP • [Code](2_variables.php)

3. Create a PHP program that uses if-else statements to check if a number is positive, negative, or zero. Utilize different operators for comparison • [Code](3_if-else.php)

4. Develop a function that calculates the average of an array of numbers. Test the function with various arrays • [Code](4_function.php)

5. Define a PHP class representing a "Book" with properties like title and author. Create objects of this class and display their attributes. • [Code](5_class.php)

6. Design a simple HTML form with input fields. Create a PHP script that retrieves and displays the form data when submitted. • [Code](6_form_retrieval.php)

7. Enhance the previous form with PHP validation. Ensure that required fields are filled, and validate email addresses and make sure the phone number starts with 98 or 97 using regex • [Code](7_enhancement_of_6.php)

8. Implement PHP code that responds to a button click event on a form. Display a message when the button is clicked • [Code](8_button_click.php)

9. Create a PHP script that sets a cookie with user preferences.Retrieve and display this information on subsequent visits • [Code](9_cookies.php)

10. Build a form with various elements (textboxes, checkboxes, radio buttons). Use PHP to access and display the selected values • [Code](10_form.php)

11. Develop a PHP script that reads content from a text file, modifies it, and then writes the updated content back to the file • [Code](11_file.php)

## Lab 4.1 Connecting to database

1. Write PHP code to establish a connection to a MySQL database, including the necessary credentials.
2. Develop a PHP script to insert a new record into a MySQL database table.Ensure proper validation and sanitation of input data.
3. Create a PHP script that retrieves and displays all records from a MySQL database table.
4. Modify a specific record in a MySQL table using PHP. Ensure that the update is based on user input or specific criteria.
5. Implement PHP code to delete a record from a MySQL table. Provide options for the user to select the record to be delete
1. Write PHP code to establish a connection to a MySQL database, including the necessary credentials • [Code](Connecting_to_database/1_connection.php)

2. Develop a PHP script to insert a new record into a MySQL database table.Ensure proper validation and sanitation of input data • [Code](Connecting_to_database/2_insert.php)

3. Create a PHP script that retrieves and displays all records from a MySQL database table • [Code](Connecting_to_database/3_retrieve.php)

4. Modify a specific record in a MySQL table using PHP. Ensure that the update is based on user input or specific criteria • [Code](Connecting_to_database/4_edit.php)

5. Implement PHP code to delete a record from a MySQL table. Provide options for the user to select the record to be delete • [Code](Connecting_to_database/5_delete.php)
Empty file.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Description

This is a code repository for all the major lab codes necessary for CSIT students according to semester in subject-wise format, currently in 5<sup>th</sup> semester and is being updated.
This is a code repository for all the major lab codes necessary for CSIT students according to semester in subject-wise format, currently in 6<sup>th</sup> semester and is being updated.

_Please feel free to update the codes as per needs and contribute to the repository._

Expand Down Expand Up @@ -47,6 +47,11 @@ _Please feel free to update the codes as per needs and contribute to the reposit
- [Web Technology](/5th_Semester/Web_Technology/README.md)
- [Cryptography](/5th_Semester/Cryptography/README.md)

## [6<sup>th</sup> Semester](/6th_Semester/README.md)

- [Compiler Design](/6th_Semester/Compiler_Design/README.md)
- [Software Engineering](/6th_Semester/Software_Engineering/README.md)

## Contributing

1. Fork it.
Expand Down

0 comments on commit b93f943

Please sign in to comment.