Past Papers, UOS Main Campus, Web System and Technologies

Web System & Technologies Past Paper 2018 – BSSE 3rd Term UOS (IT-3548)

ProgramBSSE
Term3rd
Year2018
Course codeIT-3548
AnswersSolved ✓

University of Sargodha BS Software Engineering 3rd term examination 2018, Web System & Technologies (IT-3548) paper (80 marks, 2:30 hours). The paper is retyped by Shining Study from a student’s copy (marks, names and roll numbers removed); all answers are written by Shining Study for revision. Solved answers for all 16 short questions, a tested HTML + PHP sports form (sport.php), three-tier architecture and a PHP/MySQL movie insert program. Page 2 of the paper was not available.

Solved answers

Q1 – Short answers (16 × 2)

i. Internal links in HTML. Give the target element an id and link to it with #: <a href="#contact">Go to Contact</a> ... <h2 id="contact">Contact</h2>. Links to other pages of the same site use relative URLs, e.g. <a href="about.html">.

ii. Protocol between web server and client. HTTP (HyperText Transfer Protocol), or its secure form HTTPS, running over TCP/IP.

iii. Cell padding vs cell spacing. Cell padding is the space between a cell’s border and its content (inside the cell). Cell spacing is the space between neighbouring cells (outside the cells). Diagram: [ border |padding| content |padding| border ] <-spacing-> [ next cell ]. In CSS: td { padding: 8px; } and table { border-spacing: 5px; }.

iv. Relative vs absolute position. position: relative moves an element relative to its normal position and keeps its space in the layout. position: absolute removes it from the normal flow and places it relative to the nearest positioned ancestor (or the page).

v. Inline vs block elements. Block elements start on a new line and take the full width (div, p, h1, ul). Inline elements stay in the line and take only the needed width; width/height do not apply (span, a, b, img).

vi. Automatic type conversion in JavaScript. Yes – JavaScript does implicit type coercion: "5" + 2 gives "52", "5" * 2 gives 10, true + 1 gives 2 (checked in Node.js). Use === to compare without conversion.

vii. Hiding an HTML element. CSS display:none (removes it from layout) or visibility:hidden (keeps the space); JavaScript: document.getElementById("x").style.display = "none";; HTML5 attribute hidden.

viii. Margin vs padding. Padding is the space inside the border (between border and content) and takes the element’s background; margin is the space outside the border between elements and is transparent.

ix. jQuery vs JavaScript. JavaScript is the programming language; jQuery is a library written in JavaScript that provides shorter syntax for DOM, events, effects and AJAX, e.g. $("#x").hide() vs document.getElementById("x").style.display="none".

x. Horizontal menu from an unordered list. ul { list-style: none; } li { display: inline-block; margin-right: 15px; } (or ul { display: flex; } or li { float: left; }).

xi. mysql_fetch_array() vs mysql_fetch_assoc(). mysql_fetch_array() returns a row as both a numeric and associative array ($row[0] and $row["name"]); mysql_fetch_assoc() returns only the associative array. (The old mysql_ functions are removed in PHP 7; use mysqli_fetch_array()/mysqli_fetch_assoc() or PDO.)

xii. Associative array. An array whose keys are named strings: $age = ["Ali" => 21, "Sara" => 22]; echo $age["Ali"];

xiii. Importance of the action attribute. It gives the URL of the server-side script that will receive and process the form data when it is submitted, e.g. <form action="save.php" method="post">. If omitted, the data is sent to the same page.

xiv. Current date and time in JavaScript. var d = new Date(); document.write(d.toLocaleDateString() + " " + d.toLocaleTimeString());

xv. JavaScript vs JScript. JScript was Microsoft’s own implementation of ECMAScript for Internet Explorer; JavaScript is Netscape/Mozilla’s implementation. They are almost the same, with small browser-specific differences; JScript is now obsolete.

xvi. Initiate a session in PHP. Call session_start(); at the top of the page before any output, then store values: $_SESSION["user"] = "Ali";

Q2 – Sports form (HTML) and sport.php

sport.html

<!DOCTYPE html>
<html>
<head><title>Sports Survey</title></head>
<body>
  <form action="sport.php" method="post">
    Student name: <input type="text" name="sname"><br><br>
    Sports you like watching:<br>
    <input type="checkbox" name="sports[]" value="Baseball"> Baseball<br>
    <input type="checkbox" name="sports[]" value="Basketball"> Basketball<br>
    <input type="checkbox" name="sports[]" value="Football"> Football<br>
    <input type="checkbox" name="sports[]" value="Volleyball"> Volleyball<br><br>
    <input type="submit" value="Submit">
  </form>
</body>
</html>

sport.php

<?php
$name = htmlspecialchars($_POST["sname"] ?? "");
$sports = $_POST["sports"] ?? [];

echo "<h3>Student name: $name</h3>";
if (count($sports) > 0) {
    echo "<p>Sports you like:</p><ul>";
    foreach ($sports as $s) {
        echo "<li>" . htmlspecialchars($s) . "</li>";
    }
    echo "</ul>";
} else {
    echo "<p>You did not select any sport.</p>";
}
?>

Checkbox names end with [] so PHP receives all ticked sports as an array. Tested in PHP 8 with name “Sara” and Football + Volleyball: it prints the name and a list of the two sports.

Q3 – Three-tier web application architecture

  [ Tier 1: Presentation ]      [ Tier 2: Application / Logic ]      [ Tier 3: Data ]
   Browser (HTML, CSS, JS)  <-->  Web server + PHP/Java/.NET     <-->  Database server
   user interface            HTTP   business rules, validation   SQL   (MySQL, Oracle)
          request  ------------------->   query  ------------------->
          response <-------------------   result <-------------------
  1. The user fills a form in the browser (presentation tier) and submits it; an HTTP request goes to the web server.
  2. The application tier (e.g. PHP) validates input, applies business rules and builds SQL queries.
  3. The data tier (DBMS) executes the query and returns the result.
  4. The application tier formats the result as HTML/JSON and sends the response back to the browser, which displays it.

Advantages: separation of concerns, each tier can be developed, scaled and secured independently (the database is never exposed directly to clients), easier maintenance and reuse.

Q4 – PHP program to insert movie information

The page-2 part showing the exact Movie table is not in our copy, so we assume the table Movie(title VARCHAR, director VARCHAR, release_year INT) in the database Movie; adjust the column names to match the table given in the exam.

CREATE DATABASE Movie;
USE Movie;
CREATE TABLE Movie (
  id INT AUTO_INCREMENT PRIMARY KEY,
  title VARCHAR(100),
  director VARCHAR(100),
  release_year INT
);
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $title    = trim($_POST["txtTitle"]);
    $director = trim($_POST["txtDirector"]);
    $year     = (int) $_POST["txtYear"];

    $conn = new mysqli("localhost", "root", "", "Movie");
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $stmt = $conn->prepare("INSERT INTO Movie (title, director, release_year) VALUES (?, ?, ?)");
    $stmt->bind_param("ssi", $title, $director, $year);
    if ($stmt->execute()) {
        echo "Movie saved successfully.";
    } else {
        echo "Error: " . $stmt->error;
    }
    $stmt->close();
    $conn->close();
}
?>
<form method="post">
  Title of movie: <input type="text" name="txtTitle"><br>
  Director's name: <input type="text" name="txtDirector"><br>
  Released Year of movie: <input type="text" name="txtYear"><br>
  <input type="submit" value="Save">
</form>

A prepared statement is used to avoid SQL injection. Syntax checked with php -l.

Questions 5 onwards are on page 2 of this paper, which we do not have.

Save this paper for offline studyDownload the question paper, or save the paper together with all solved answers as a PDF.
↓ Download Paper (JPG)
Have another year of Web System and Technologies?

Upload a photo in 10 seconds — no form to fill. We clean it, solve it and credit you.

Missing years for this subject
202420232022

About Saif R

An educator and technology enthusiast passionate about empowering students through quality education and digital learning. Dedicated to making academic resources and opportunities accessible to everyone.