WPjash
WPjash
PRACTICAL-5
a) Create a page using java script, which sorts elements of array
in ascending array using bubble sort.
var arr = [5,6,3,1,2,4];
bubbleSortAlgo(arr);
function bubbleSortAlgo(arr){
for(var i=0;i<arr.length;i++){
var flag=false;
for(var j=0;j<arr.length-i-1;j++)
{ if(arr[j]>arr[j+1]){
var tempValue=
arr[j]; arr[j]=arr[j+1];
arr[j+1]=tempValue;
flag=true;
}
}
if(flag==false)
break;
}
console.log("SORTED ARRAY");
console.log(arr);
}
OUTPUT:
<!DOCTYPE html>
<html>
<head>
<title>Alert</title>
<script type="text/javascript">
function display()
{
alert(PARTH.tbox.value);
}
</script>
</head>
<body>
<form name="PARTH">
Enter some text: <input type="text" name="tbox">
<input type="submit" onclick="display()">
</form>
</body>
</html>
OUTPUT:
<!DOCTYPE html>
<html>
<head>
<title>calculator</title>
<script>
function calc()
{
var n1 = parseFloat(document.getElementById('n1').value);
var n2 = parseFloat(document.getElementById('n2').value);
var oper = document.getElementById('operators').value;
if(oper === '+')
{
document.getElementById('result').value = n1+n2;
}
if(oper === '-')
{
document.getElementById('result').value = n1-n2;
}
if(oper === '/')
{
document.getElementById('result').value = n1/n2;
}
if(oper === 'X')
{
document.getElementById('result').value = n1*n2;
}
}
</script>
</head>
<body>
Enter number 1: <input type="text" id="n1"/><br/><br/>
Enter number 2: <input type="text" id="n2"/><br/><br/>
<select id="operators">
<option value="+">+</option>
<option value="-">-</option>
<option value="/">/</option>
<option value="X">X</option>
</select>
<button onclick="calc();">=</button>
<input type="text" id="result"/>
</body>
</html>
OUTPUT:
<!DOCTYPE html>
<html>
<head>
<title>odd-even</title>
<script>
function display()
{
var n1 = parseInt(document.getElementById('n1').value);
var n2 = parseInt(document.getElementById('n2').value);
document.write("Odd,even numbers between ["+n1+","+n2+"] are: <br>");
for(i=n1;i<=n2;i++)
{ if(i
%2===0)
{document.write(i+": even<br>");}
else
{document.write(i+": odd<br>");}
}
}
</script>
</head>
<body>
<form name="form1" onsubmit="display()">
Enter number 1: <input type="text" id="n1"/><br/><br/>
Enter number 2: <input type="text" id="n2"/><br/><br/>
<input type="submit">
</form>
</body>
</html>
OUTPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Form</title>
</head>
<body>
<h1>Registration Form</h1>
<form onsubmit="return validateForm()">
<label for="name">Name:</label>
<input type="text" id="name" required>
<br><br>
<label for="password">Password:</label>
<input type="password" id="password" required minlength="6">
<br><br>
<label for="address">Address:</label>
<textarea id="address" required></textarea>
<br><br>
<label for="phone">Phone No.:</label>
<input type="tel" id="phone" required pattern="[0-9]+"> <br><br>
<label for="email">Email:</label>
<input type="email" id="email" required>
<br><br>
<label>Gender:</label>
<input type="radio" id="male" name="gender" value="male" required>
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female" required>
<label for="female">Female</label>
<br><br>
<label>Hobbies:</label>
<input type="checkbox" id="hobby_reading" name="hobby[]" value="reading"> Read
<input type="checkbox" id="hobby_movies" name="hobby[]" value="movies"> Movies
<input type="checkbox" id="hobby_sports" name="hobby[]" value="sports"> Sports
<br><br>
<label for="country">Country:</label>
<select id="country" required>
<option value="">Select Country</option>
<option value="India">India</option>
<option value="USA">USA</option>
<option value="Canada">Canada</option>
<option value="UK">UK</option>
<option value="Australia">Australia</option>
<option value="Germany">Germany</option>
<option value="France">France</option>
<option value="Japan">Japan</option>
<option value="China">China</option>
<option value="Brazil">Brazil</option>
</select>
<br><br>
<button type="submit">Submit</button>
<button type="reset">Reset</button>
<p id="error-message"></p>
</form>
<script>
function validateForm()
{ var errorMessage = "";
var email = document.getElementById("email").value;
errorMessage = "Invalid email format. Please enter a valid email address (e.g.,
[email protected])";
}
// If validation passes, submit the form (replace with your form submission logic)
alert("Data submitted successfully!");
return true;
}
</script>
</body>
</html>
OUTPUT:
<html>
<head>
<title>color-color</title>
<script type="text/javascript">
</script>
</head>
<body>
</body>
</html>
OUTPUT:
g) Write a script to open window having specific width, height and with
a status bar on button click.
<html>
<head>
</head>
<script type="text/javascript">
function poponload()
</script>
<body>
</body>
</html>
OUTPUT:
<head>
<title>JS windows</title>
</head>
<script type="text/javascript">
function poponload()
window.open("http://www.google.com/");
</script>
<body>
</body>
</html>
OUTPUT:
<head>
<title>Cross-Window HTML</title>
<script>
function newHTML()
HTMLstring='<html>\n';
HTMLstring+='<p>'+mainform.word.value+'</p>\n';
HTMLstring+='</html>';
newwindow=window.open();
newdocument=newwindow.document;
newdocument.write(HTMLstring);
newdocument.close();
</script>
</head>
<body>
<form name="mainform">
<br><br>
</form>
</body>
</html>
OUTPUT:
j) Write a script to hide the text when hide button is clicked and to show
the text when show button is clicked.
<html>
<head>
<title>FORM</title>
<script type="text/javascript">
function myFunction()
var x = document.getElementById("myInput");
x.type = "text";
} else
x.type = "password";
</script>
</head>
<body>
<form>
</form>
</body>
</html>
OUTPUT:
PRACTICAL-6
HTML
<?php
// Your PHP code goes here
?>
<!DOCTYPE html>
<html>
<head>
<title>Your Page Title</title>
</head>
<body>
<?php
// More PHP code (optional)
?>
</body>
</html>
Key PHP Features:
Variables: Store and manage data using variables with different data types (strings, integers,
arrays, etc.).
Operators: Perform operations on variables and data (arithmetic, comparison, logical, etc.).
Control Flow Statements: Control the flow of execution using if, else, for, while, and other
statements.
Functions: Create reusable blocks of code for modularity and better organization.
Object-Oriented Programming (OOP): PHP supports object-oriented programming concepts
like classes, objects, inheritance, and more (optional for beginners).
=>MYSQL
SQL stands for Structured Query Language. It's a standardized language used to manage data
stored in relational databases. Here's a breakdown of key concepts:
1. Relational Databases:
Rows represent individual records within a table (e.g., each customer record).
Columns represent attributes or characteristics of those records (e.g., customer name, email,
address).
2. SQL Functionality:
Examples: SELECT, FROM, WHERE, ORDER BY, JOIN (to combine data from multiple
tables).
4. Advantages of SQL:
b) Create php page with name 1.php With fields username and
password. 2 buttons ok and cancel. On click of ok button data filled in
the fields should be displayed on the next page.(use post and get method)
1. php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login Form</title>
</head>
<body>
<h1>Login</h1>
<label for="username">Username:</label>
<label for="password">Password:</label>
<button type="submit">OK</button>
<button type="reset">Cancel</button>
</form>
</body>
</html>
2. php
<?php
$username = $_POST["username"];
$password = $_POST["password"];
// Display the received information (replace with your logic for processing)
} else {
?>
OUTPUT:
c) Create php page with name 1.php With fields username and password.
2 buttons ok and cancel. On click of ok button Retrieve the username &
password and check if username= “admin” and password=”admin” go to
admin.php. if username= “visitor” and password=”visitor” go to
visitor.php.
login.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>
</head>
<body>
<h1>Login</h1>
<label for="username">Username:</label>
<label for="password">Password:</label>
<button type="submit">OK</button>
<button type="reset">Cancel</button>
</form>
<?php
$username = $_POST["username"];
$password = $_POST["password"];
} else {
?>
</body>
</html>
admin.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin Page</title>
</head>
<body>
<h1>Welcome Admin!</h1>
</body>
</html>
visitor.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Visitor Page</title>
</head>
<body>
<h1>Welcome Visitor!</h1>
</body>
</html>
OUTPUT:
d) Create and php page with name cookie.php with fields Name, surname,
email-id, phone_no and city. 2 buttons ok and cancel. On click of ok
button page should go to 1.php where it should contain a link with the
name show details and on click of it other page should be open which
shows you the details which you have filled in cookie.php page (make use
of cookies).
cookie.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Enter Details</title>
</head>
<body>
<label for="name">Name:</label>
<label for="surname">Surname:</label>
<label for="email">Email:</label>
<label for="city">City:</label>
<button type="submit">OK</button>
<button type="reset">Cancel</button>
</form>
</body>
</html>
one.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome</title>
</head>
<body>
<h1>Welcome!</h1>
</body>
</html>
details.php
<?php
if (isset($_COOKIE["user_details"])) {
} else {
echo "No details found. Please enter your details on the cookie.php page.";
OUTPUT:
e) Create and php page with name cookie.php With fields Name , surname,
email-id, phone_no and city. 2 buttonsok and cancel. On click of ok button
page should go to 1.php where it should contain link with name show
details and on click of it other page should be open which shows you the
details which you have filled in cookie.php page.(make use of session)
cookie1.php
<?php
session_start();
if(isset($_POST['submit'])){
$_SESSION['name'] = $_POST['name'];
$_SESSION['surname'] = $_POST['surname'];
$_SESSION['email'] = $_POST['email'];
$_SESSION['phone_no'] = $_POST['phone_no'];
$_SESSION['city'] = $_POST['city'];
header("Location: session1.php");
exit;
?>
<!DOCTYPE html>
<html>
<head>
<title>Cookie Form</title>
</head>
<body>
</form>
</body>
</html>
session1.php
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Show Details</title>
</head>
<body>
</body>
</html>
details1.php
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Details</title>
</head>
<body>
<h2>Details</h2>
</body>
</html>
OUTPUT:
PRACTICAL-7
<html>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "admin";
$conn = new mysqli($servername, $username, $password); if ($conn->connect_error)
{die("Connection failed: " . $conn->connect_error);
}
$sql2 = "CREATE TABLE personal_info( name VARCHAR(30),
password VARCHAR(30), address VARCHAR(30), phoneno VARCHAR(30),
email VARCHAR(50))"; $dbname="student_info";
$conn->query($sql3);
$conn->query($sql4);
$conn->query($sql5);
OUTPUT:
Formdb.php
<!DOCTYPE html>
<html>
<body>
<form method="post" action="formdb2.php" id="form">
<label>ID: </label><input type="text" name="id"/><br>
<label>First Name : </label><input type="text" name="fname"/><br>
<label>Last Name : </label><input type="text" name="lname"/><br>
<label>Email-id : </label><input type="text" name="email"/><br>
<label>Phone-no : </label><input type="text" name="phoneno"/><br>
<label>City : </label><input type="text" name="city"/><br>
<input type="submit" name="submit" value="OK">
<input type="reset" value="Cancel">
<br></form>
<button
onclick="window.location.href='delete.php'">Deleterecord</button>
<br>
<button onclick="window.location.href='update.php'">Update
record</button>
</body>
</html>
Formdb2.php
<html>
<body>
<h2>Values are updated!</h2>
<br>
<?php
$vo=$_POST["id"];
$v1=$_POST["fname"];
$v2=$_POST["lname"];
$v3=$_POST["email"];
$v4=$_POST["phoneno"];
$v5=$_POST["city"];
?>
<?php
$mysqli = new mysqli("localhost","root","vb","practical8b");
$mysqli -> query("CREATE TABLE practical8btable( id
VARCHAR(10), fname VARCHAR(30), lname VARCHAR(30), email
VARCHAR(30),
phoneno VARCHAR(30), city VARCHAR(30)
)");
Displaytable.php
<html>
<body>
<h2>Your table!</h2><br>
<?php
$mysqli = new mysqli("localhost","root","vb","practical8b");
$sql = "select * from practical8btable"; echo '<table
border="1">
<tr>
<td>ID</td> <td>First Name</td>
<td>Last name</td>
<td>Email-id</td>
<td>Phone-no</td>
<td>City</td>
</tr>;
if ($result = $mysql->
query($sql))
{
while ($row = $result->
fetch_assoc())
{
$field0name = $row["id"];
$field1name = $row["fname"];
$field2name = $row["lname"];
$field3name = $row["email"];
$field4name = $row["phoneno"];
$field5name = $row["city"];
echo '<tr>
<td>'.$field0name.'</td>
<td>'.$field1name.'</td>
<td>'.$field2name.'</td>
<td>'.$field3name.'</td>
<td>'.$field4name.'</td>
<td>'.$field5name.'</td>
</tr>';
}
$result->free();
}
?>
</body>
</html>
Delete.php
<!DOCTYPE html>
<html>
<body>
<h2>Deletion page!</h2>
<form method="post" action="deleteid.php" id="form">
<label>Enter the ID of the person whose record you want to delete :
</label>
<input type="text" name="delid"/><br>
<input type="submit" name="submit" value="Delete">
</form>
</body>
</html>
Deleteid.php
<!DOCTYPE html>
<html>
<body>
<h2>Record Deleted!</h2>
<br>
<?php
$mysqli = new mysqli("localhost","root","vb","practical8b");
$v0=$_POST["delid"];
$mysqli -> query("DELETE FROM practical8btable where
id='$v0'"); $mysqli -> close();
OUTPUT:
PRACTICAL-8
<!DOCTYPE html>
<html>
<body>
<div id="demo">
<h2>The XMLHttpRequest Object</h2>
<button type="button" onclick="loadDoc()">Change Content</button>
</div>
<script>
function loadDoc() {
const xhttp = new XMLHttpRequest();
xhttp.onload = function() {
document.getElementById("demo").innerHTML =
this.responseText;
}
xhttp.open("GET", "ajax_info.txt");
xhttp.send();
}
</script>
</body>
</html>
ajax_info.txt
OUTPUT:
<!DOCTYPE html>
<html>
<body>
<div id="demo">
<h2>The XMLHttpRequest Object</h2>
<button type="button" onclick="loadDoc('ajax_info.txt', myFunction)">Change Content
</button>
</div>
<script>
function loadDoc(url, xFunction)
{ const xhttp=new
XMLHttpRequest();
xhttp.onload = function() {xFunction(this);}
xhttp.open("GET", url);
xhttp.send();
}
function myFunction(xhttp)
{ document.getElementById("demo").innerHTML = xhttp.responseText;
}
</script>
</body>
</html>
ajax_info.txt
OUTPUT:
PRACTICAL-9
(BEYOND SYLLABUS)
=>Front-End Development
React, Angular, Vue.js: These popular JavaScript libraries (frameworks) continue to dominate
the front-end landscape, each offering different strengths and approaches to building user
interfaces. They allow for component-based architecture, reusability, and efficient
development.
Svelte: Gaining traction, Svelte is a compiler-based framework that offers a unique approach.
It compiles code during the build process, resulting in smaller bundle sizes and potentially
faster performance compared to traditional frameworks.
WebAssembly (WASM): WASM allows running code written in languages like C++ or Rust
within web browsers. This can be beneficial for performance-critical tasks like complex
animations or 3D graphics, as it leverages the efficiency of compiled languages.
Progressive Web Apps (PWAs): PWAs offer app-like experiences within the browser.
They can be installed on home screens, work offline, and leverage push notifications,
providing a more engaging user experience.
CSS-in-JS Libraries: Libraries like styled-components or Emotion allow you to write CSS
code directly within your JavaScript components, promoting better maintainability and
styling flexibility.
=>Back-End Development:
Node.js: Node.js remains a popular choice for building scalable and efficient server-side
applications. Its event-driven architecture makes it suitable for real-time applications and
APIs.
Serverless Computing: Cloud platforms like AWS Lambda or Google Cloud Functions allow
you to build and deploy code without managing servers. This serverless approach facilitates
faster development and reduces infrastructure management overhead.
GraphQL: GraphQL is an API query language that allows clients to request specific data from
an API. This can improve performance and flexibility compared to traditional REST APIs.
Headless CMS: Headless CMS systems decouple the content management system from the
front-end. This allows developers to choose any front-end framework while managing
content centrally.
Git version control: Git remains an essential tool for managing code versions and
collaboration among developers.
Containerization (Docker, Kubernetes): Containerization technologies like Docker package
applications with their dependencies, making them portable and easier to deploy across
different environments. Kubernetes helps manage containerized applications at scale.
Cloud Platforms (AWS, Azure, GCP): Cloud platforms offer a variety of services for
building, deploying, and scaling web applications. They provide infrastructure, databases,
serverless functions, and other tools that streamline development and deployment.