UNIT I
UNIT I
HTML
1. What is HTML?
html
CopyEdit
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
o Tags define elements (<p>, <h1>, <a>), and attributes provide additional
information (href, src, alt).
5. What is an iframe?
html
CopyEdit
<iframe src="page.html"></iframe>
6. What is DHTML?
o Forms collect user input with elements like <input>, <textarea>, <select>,
<button>.
CSS
1. What is XML?
o DOM loads entire XML into memory; SAX is event-driven, faster for large files.
6. What is XHTML?
JavaScript
js
CopyEdit
function greet() {
alert("Hello!");
js
CopyEdit
let person = {
name: "John",
age: 30
};
js
CopyEdit
this.name = name;
this.age = age;
1. What is JSP?
o JSP allows embedding Java code in HTML using special JSP tags.
o Directives (<%@ %>), Declarations (<%! %>), Scriptlets (<% %>), Expressions
(<%= %>).
1. What is PHP?
php
CopyEdit
<?php
?>
php
CopyEdit
$conn = mysqli_connect("localhost", "root", "", "db_name");
3. What is PHPMyAdmin?
php
CopyEdit
mysqli_query($conn, $sql);
o Keeping track of user data between requests using cookies, sessions, query
strings.
4. Form validation: Check email format and phone number using JavaScript.
5. Write an XML file for student data and define its structure.
7. How does the login system using PHP work with password verification?
Would you like me to generate these Q&As as a print-ready PDF document or a flashcard
deck for revision?
4o
You said:
How do you create a frame layout in HTML? How to apply all 3 types of CSS in a project?
Write JavaScript to detect even/odd numbers. Form validation: Check email format and
phone number using JavaScript. Write an XML file for student data and define its structure.
Explain PHP script to display data from a .txt file in a table. How does the login system using
PHP work with password verification? Steps to insert and display user data using PHP +
MySQL. Explain working of XAMPP and how to verify server is running. How does JavaScript
handle button click events? Write code to design a calculator using JavaScript. How do you
design an online quiz in JavaScript? solutions
ChatGPT said:
html
CopyEdit
<!DOCTYPE html>
<html>
<frameset rows="50%,50%">
<frameset cols="50%,50%">
</frameset>
<frame src="bottom.html" style="background:blue;">
</frameset>
</html>
Inline CSS:
html
CopyEdit
Internal CSS:
html
CopyEdit
<style>
h2 { color: blue; }
</style>
External CSS:
html
CopyEdit
Example styles.css:
css
CopyEdit
body {
background-color: #f0f0f0;
CopyEdit
<!DOCTYPE html>
<html>
<head>
<title>Even or Odd</title>
</head>
<body>
<button onclick="check()">Check</button>
<p id="result"></p>
<script>
function check() {
const n = parseInt(document.getElementById("num").value);
if (isNaN(n)) {
} else if (n % 2 === 0) {
} else {
</script>
</body>
</html>
4. Form validation: Check email format and phone number using JavaScript.
html
CopyEdit
<!DOCTYPE html>
<html>
<body>
</form>
<script>
function validateForm() {
if (!emailPattern.test(email)) {
return false;
if (!phonePattern.test(phone)) {
return true;
</script>
</body>
</html>
5. Write an XML file for student data and define its structure.
xml
CopyEdit
<students>
<student>
<enrollment>MAIT202401</enrollment>
<name>Rohit Sharma</name>
<mobile>9876543210</mobile>
<email>rohit@example.com</email>
</student>
<student>
<enrollment>MAIT202402</enrollment>
<name>Neha Verma</name>
<mobile>9123456780</mobile>
<email>neha@example.com</email>
</student>
</students>
6. Explain PHP script to display data from a .txt file in a table.
File: users.txt
ruby
CopyEdit
Rohit:12345:rohit@example.com
Neha:abcde:neha@example.com
PHP Script:
php
CopyEdit
<?php
$filename = "users.txt";
if (file_exists($filename)) {
echo "<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td></tr>";
fclose($file);
} else {
echo "</table>";
?>
7. How does the login system using PHP work with password verification?
Steps:
1. Create an HTML form to collect username and password.
perl
CopyEdit
admin:$2y$10$abcDEFHashed...
PHP Script:
php
CopyEdit
<?php
$inputUser = $_POST['username'];
$inputPass = $_POST['password'];
exit;
?>
php
CopyEdit
<?php
$name = $_POST['name'];
$address = $_POST['address'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$sql = "INSERT INTO users (name, address, email, mobile) VALUES (?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->execute();
?>
php
CopyEdit
<?php
echo "<table
border='1'><tr><th>ID</th><th>Name</th><th>Address</th><th>Email</th><th>Mobile</t
h></tr>";
echo
"<tr><td>{$row['id']}</td><td>{$row['name']}</td><td>{$row['address']}</td><td>{$row['e
mail']}</td><td>{$row['mobile']}</td></tr>";
}
echo "</table>";
?>
2. Steps:
o Install XAMPP.
o Go to http://localhost in browser.
html
CopyEdit
<script>
function showAlert() {
alert("Button clicked!");
</script>
js
CopyEdit
document.getElementById("btn").addEventListener("click", showAlert);
html
CopyEdit
<input id="num1">
<select id="op">
<option value="+">+</option>
<option value="-">-</option>
</select>
<input id="num2">
<button onclick="calc()">=</button>
<p id="res"></p>
<script>
function calc() {
let n1 = parseFloat(document.getElementById('num1').value);
let n2 = parseFloat(document.getElementById('num2').value);
let op = document.getElementById('op').value;
let res;
switch(op) {
</script>
html
CopyEdit
<form id="quizForm">
</form>
<p id="result"></p>
<script>
function scoreQuiz() {
let score = 0;
score++;
</script>