WT Allexp
WT Allexp
Steps to Install:
Step 1:
Open the XAMPP website. Go to https://www.apachefriends.org/index.html in your
Step 2:
Click XAMPP for Windows. It's a grey button near the bottom of the page.
Depending on your browser, you may first have to select a save location or
verify the download.
Step 3:
Double-click the downloaded file. This file should be named something like xampp-
win32-7.2.4-0-VC15-installer, and you'll find it in the default downloads location
(e.g., the "Downloads" folder or the desktop).
Step 4:
Click Next. It's at the bottom of the setup window.
Step 5:
Select aspects of XAMPP to install. Review the list of XAMPP attributes on the left
side of the window; if you see an attribute that you don't want to install as part of
XAMPP, uncheck its box.
If you have the UAC activated on your computer, avoid installing XAMPP in
your hard drive's folder (e.g., OS (C:)).
You can select a folder (e.g., Desktop) and then click Make New Folder to
create a new folder and select it as the installation destination.
Step-7:
Begin installing XAMPP. Click Next at the bottom of the window to do so. XAMPP will begin
Step-9:
When you do this, you'll see red X marks to the left of each server type (e.g.,
"Apache"). Clicking one of these will prompt you to click Yes if you want to
install the server type's software on your computer.
Step-11:
Resolve issues with Apache refusing to run. On some Windows 10 computers, Apache
won't run due to a "blocked port". This can happen for a couple of reasons, but there's a
relatively easy fix:[1]
Scroll down to the "Listen 80" section (you can press Ctrl+F and type in l i s t e n 8 0 to
find it faster).
Replace 8 0 with any open port (e.g., 8 1 or 9 0 8 0 ).
Press Ctrl+S to save the changes, then exit the text editor.
Restart XAMPP by clicking Quit and then re-opening it in administrator mode from its
folder.
Experiment 2:
Write an Html Page include javascript that takes a given set of Integer number and
shows them after sorting in descending order
Source Code:
Sortdesc.html
<html>
<head>
<script language="javascript">
function ndesc() {
document.forms["frm1"].desc.value = "";
num_array.push(nums[i]);
function sortN(a, b) {
return b - a;
}
document.forms["frm1"].desc.value = num_array.sort(sortN);
</script>
</head>
<body>
<form name="frm1">
<center>
</center>
<br />
<br />
<center>
</center>
<br />
</form>
</body>
</html>
Output:
Experiment 3:
Write an HTML page including any required JavaScript that takes a number from
one text field in the range of 0 to 999 and shows it in another text field in words. If the
number is out of range, it should show “out of range” and if it is not a number, it
should show “not a
number” message in the result box.
Source Code:
Conv.html
<html>
<head>
<title>Number in words</title>
<script language="javascript">
function convert() {
document.forms["frm1"].words.value = "";
if (isNaN(num)) {
alert("Not a Number");
alert("Out of Range");
}
else {
switch (n) {
document.forms["frm1"].words.value = words;
</script>
</head>
<body>
<form name="frm1">
<center>
<h3>NUMBER IN WORDS</h3>
</center>
<br />
<br />
<br />
</form>
</body>
</html>
Output:
Experiment 4:
Write an HTML page that has one input, which can take multi line text and a submit
button. Once the user clicks the submit button, it should show the number of
characters, words and lines in the text entered using an alert message. Words are
separated with white space and lines are separated with new line character.
Exp4.html
<html>
<head>
<title>Lines,words,characters</title>
<script language="javascript">
function count()
var str=document.getElementById('inputstring').value;
var result='';
var a=str.split('\n');
alert(result);
</script></head>
<body>
<form name="frm1">
</form>
</body>
</html>
Output:
Input:
Result:
Experiment 5:
Write an HTML page that contains a selection box with a list of 5 countries. When
the user selects a country, its capital should be printed next to the list. Add CSS to
customize the properties of the font of the capital (color, bold and font size).
Exp5.html
<html>
<title>Capitals of Countries</title>
<head>
<style>
h1{
color:blue;
font-family:verdana;
font-size:300%;
}
select{
appearance: none;
background-color: #fff;
border: 3;
border-radius: 0.35em;
margin: 0;
width: 40%;
font-family: verdana;
font-size: inherit;
cursor: pointer;
line-height: inherit;
</style>
<script language="javascript">
function OnDropDownChange(dropDown)
</script>
</head>
<body>
<center>
<option value="Paris">France</option>
<option value="Athens">Greece</option>
<option value="Madrid">Spain</option>
<option value="Beijing">China</option>
<option value="Islamabad">Pakistan</option>
<option value="Japan">Japan</option>
</select>
</center>
</form>
</body>
</html>
Output :
Selection of Value:
a)DOM parser
b)SAX parser
Procedure: write the java and xml files. Compile and run the java file.
AIM: Takes User Id as input and returns the user details using XML with DOM
Java DOM Parser: DOM stands for Document Object Model. The DOM API provides
the classes to read and write an XML file. DOM reads an entire document. It is useful
when reading small to medium size XML files. It is a tree-based parser and a little slow
when compared to SAX and occupies more space when loaded into memory. We
can insert and delete nodes using the DOM API.
We have to follow the below process to extract data from an XML file in Java.
PROGRAM:
employees.xml
<employees>
<employee id="111">
<firstName>Naresh</firstName>
<lastName>Gupta</lastName>
<location>India</location>
</employee>
<employee id="222">
<firstName>Kumar</firstName>
<lastName>Gussin</lastName>
<location>Russia</location>
</employee>
<employee id="333">
<firstName>David</firstName>
<lastName>Feezor</lastName>
<location>USA</location>
</employee>
<employee id="444">
<firstName>Lokesh</firstName>
<lastName>Gupta</lastName>
<location>India</location>
</employee>
<employee id="555">
<firstName>Vishnu</firstName>
<lastName>Gussin</lastName>
<location>Russia</location>
</employee>
<employee id="666">
<firstName>Veeru</firstName>
<lastName>Feezor</lastName>
<location>USA</location>
</employee>
<employee id="777">
<firstName>Pavan</firstName>
<lastName>Feezor</lastName>
<location>USA</location>
</employee>
<employee id="888">
<firstName>Narayana</firstName>
<lastName>Gussin</lastName>
<location>Russia</location>
</employee>
<employee id="999">
<firstName>David</firstName>
<lastName>Feezor</lastName>
<location>USA</location>
</employee>
<employee id="1000">
<firstName>Sunder</firstName>
<lastName>Feezor</lastName>
<location>USA</location>
</employee>
</employees>
ReadXML.java:
import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.io.*;
import java.util.Scanner;
public class ReadXML {
public static void main(String a[]) throws Exception{
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
//Build Document
Document document = builder.parse(new
File("C:\\Users\\Naresh\\Desktop\\employees.xml"));
OUTPUT:-
Let’s now see an example on extracting data from XML using Java SAX
Parser.
Create a java file for SAX parser. In this case, we have created
GfgSaxXmlExtractor.java
student.xml
A user validation web application, where the user submits the login name and
password to the server. The name and password are checked against the data already
available in database and if the data matches, a successful login page is returned.
Otherwise a failure message is shown to the user.
Login.html
<html>
<head>
<title> Login</title>
</head>
<body>
<div align="center">
</div>
</form>
</body>
</html>
database.php
<?php
$mysql_host='localhost';
$mysql_user='root';
$mysql_password='';
$name=$_POST['Uname'];
$pwd=$_POST['pwd'];
$conn=@mysqli_connect($mysql_host,$mysql_user,$mysql_password);
if($conn)
if(@mysqli_select_db($conn,'login'))
{
//echo "successfully conected";
else
else
die('connection error');
$get=mysqli_query($conn,$query);
if($get)
while($retrieve=mysqli_fetch_assoc($get))
echo "Welcome".$name ;
return true;
}
else{
return false;
else
?>
Output:
Experiment 8:
Aim:
A user validation web application, where the user submits the login name and
password to the server. The name and password are checked against the data
already available in xml file (users.xml) and if the data matches, a successful login
page is returned. Otherwise a failure message is shown to the user.
Source Code:
users.xml
<?xml version="1.0"?>
<users>
<user>
<userid>madhu</userid>
<password>12345</password>
</user>
<user>
<userid>naveen</userid>
<password>12345</password>
</user>
<user>
<userid>durga</userid>
<password>12345</password>
</user>
<user>
<userid>ramesh</userid>
<password>12345</password>
</user>
</users>
Loginxml.php
<html>
<head>
<title>Login </title>
</head>
<body>
<tr >
</tr>
<br/>
<tr>
<td>Username : </td>
</tr>
<tr>
<td>Password : </td>
</tr>
<tr>
<td></td>
</tr>
</table>
</form>
<?php
if(isset($_POST["Submit"]))
$uname=$_POST["uname"];
$pwd=$_POST["pwd"];
foreach($xml->children() as $users)
if($users->userid==$uname)
if($users->password==$pwd)
return;
else
return;
}
echo "<center><b>Invalid Login..</b></center>";
?>
</body>
</html>
Output:
Experiment 9:
Modify the above program to use AJAX to show the result on the same page below
the
submit button.
Aim:
A user validation page web application, where the user submits the login name and
password to the server. The name and password are checked against the data
already available in database and if the data matches, a successful login Message is
returned. Otherwise a failure message is shown to the user. Use AJAX to show the
result on the same page below the button.
Index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Login</title>
</head>
<body>
<form id="loginForm">
<input type="text" placeholder="Name" id="name" required>
<input type="text" placeholder="Password" id="pwd" required>
<button type="submit">Submit</button>
</form>
<div id="result"></div>
<script>
var xhttp = new XMLHttpRequest();
var loginForm = document.getElementById('loginForm');
loginForm.addEventListener("submit",submit,false);
function submit(e)
{
e.preventDefault();
var username = document.getElementById('name').value;
var userpwd = document.getElementById('pwd').value;
var result = document.getElementById("result");
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
else{
result.innerHTML = '<h1>Wrong Details</h1>';
}
loginForm.reset();
}
};
Login.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Login</title>
</head>
<body>
<h1>Successfully logged in</h1>
</body>
</html>
Users.xml
OUTPUT:-
Experiment 10:
A simple calculator web application that takes two numbers and an operator (+,-,/,* and %)
from an HTML page and returns the result page with the operation performed on the
operands.
Calc.php
<?php
ini_set('display_errors',0);
$operator=$_REQUEST['operator'];
if($operator=="+")
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1+$add2;
if($operator=="-")
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1-$add2;
if($operator=="*")
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res =$add1*$add2;
if($operator=="/")
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1/$add2;
else if($_REQUEST['fvalue']==NULL)
else if($_REQUEST['lvalue']==NULL)
?>
<form>
<table style="border:groove #00FF99">
<tr>
<td colspan="1">
<tr>
<td>
<option>+</option>
<option>-</option>
<option>*</option>
<option>/</option>
</select></td>
</tr>
<tr>
<td class="auto-style5">
</tr>
<tr>
<td></td>
<tr>
</tr>
</table>
</form>
Output:
Experiment 11:
Modify the above program such that it stores each query in database and checks the
database first for result. If the query is already available in the DB, it returns the value that
was previously computed (from DB) or it computes the result and returns it after storing the
new query and result in DB.
<html>
<body>
<h2>Welcome</h2>
<fieldset style="width:280px">
<legend>Calculator</legend>
<form method="post">
<br/>Number 1: <input type="text" name="num1" id="num1"><br/>
<br/>Number 2: <input type="text" name="num2" id="num2"><br/>
<br/>Operation:
+ <input type="radio" name="Operation" id="add" value="+" checked="checked">
- <input type="radio" name="Operation" id="sub" value="-">
* <input type="radio" name="Operation" id="mul" value="*">
/ <input type="radio" name="Operation" id="div" value="/">
<br/><br/>
<input type="submit" name="submit" id="submit" />
<br/>
</form>
</fieldset>
<?php
if($_POST)
{
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "calc";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["result"];
}
echo "<br/> Result is displayed from database";
} else {
$resultVal=0;
switch($_POST["Operation"])
{
case "-":
echo $resultVal=$_POST["num1"] - $_POST["num2"];
break;
case "*":
echo $resultVal=$_POST["num1"] * $_POST["num2"];
break;
case "/":
echo $resultVal=$_POST["num1"] / $_POST["num2"];
break;
default:
echo $resultVal=$_POST["num1"] + $_POST["num2"];
break;
}
}
echo "</fieldset>";
}
?>
</body>
</html>
Output:
A web application that takes a name as input and on submit it shows a hello
<name> page where name is taken from the request. It shows the start time at the
right top corner of the page and provides a logout button. On clicking this button, it
should show a logout page with Thank You <name > message with the duration of
usage (hint: Use session to store name and time).
Source Code:
Login.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Session Tracking</title>
</head>
<body bgcolor="#03c6fc">
<center>
<table>
<br>
<tr></tr>
<tr></tr>
</form>
<center>
</body>
</html>
Home.php
<?php
session_start();
date_default_timezone_set("Asia/Calcutta");
$_SESSION['luser'] = $_POST['text1'];
$_SESSION['start'] = time();
$tm=$_SESSION['start'];
print "</form></center>";
?>
Logout.php
<?php
session_start();
date_default_timezone_set("Asia/Calcutta");
session_destroy();
?>
Output:
Experiment 13:
A web application that takes name and age from an HTML page. If the age is less
than 18, it should send a page with “Hello <name>, you are not authorized to visit the
site” message, where <name> should be replaced with the entered name.
Otherwise it should send “Welcome <name> to this site” message.
Source Code:
Exp13.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Age Authorization</title>
</head>
<body bgcolor="#03c6fc">
<center><h2>Enter Name and Age</h2></center>
<center>
<form method="POST">
<br><br>
<table>
<tr><td><label for="name" ><b>Name:</b></label></td>
<td><input type="name" name="name"><br></td></tr>
<br>
<tr></tr>
<tr><td><label for="age" ><b>Age:</b></label></td>
<td><input type="number" name="age"></td></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr><td colspan=2><center><input type="submit" name="Submit"
value="Submit"></center></td></tr>
</table>
</form>
</center>
<?php
if(isset($_POST["Submit"])){
// ob_end_clean();
$n=$_POST['name'];
$a=$_POST['age'];
if($a>=18){
echo
"<center><h2>Welcome</h2></center>"."<center><h2>".$n."</h2></center>";
}
else{
echo "<center><h2> Unauthorized Access
</h2></center>"."<center><h2>".$n."</h2></center>";
}
}
?>
</body>
</html>
Outputs:
Experiment 14:
The User is first served a login page which takes user’s name and password.After
Submitting the details the server check these values against the data from a
database and takes following decisions
If name and password matches , serves a welcome page with user’s full name
Source Code:
Regist.html
<!DOCTYPE html>
<html>
<head>
<title>Registration</title>
</head>
<body>
<center>
<table>
<tr>
<td>
<label for="name">Username:</label>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr></tr>
</table>
</form>
</center>
</body>
</html>
Submit1.php
<?php
$mysql_host='localhost';
$mysql_user='root';
$mysql_password='';
$name=$_POST['name'];
$pwd=$_POST['password'];
$conn=@mysqli_connect($mysql_host,$mysql_user,$mysql_password);
ob_end_clean();
if($conn)
if(@mysqli_select_db($conn,'login1'))
{}
else
else
die('connection error');
$c=0;
$c1=0;
$c2=0;
$get=mysqli_query($conn,$query);
if($get)
while($retrieve=mysqli_fetch_assoc($get))
echo "<head><title>Welcome</title></head>";
return true;
$c2+=1;
else{
$c++;
$c1++;
else{
else
Submit2.php
<?php
$mysql_host='localhost';
$mysql_user='root';
$mysql_password='';
$name=$_POST['new_user'];
$pwd=$_POST['new_pass'];
$conn=@mysqli_connect($mysql_host,$mysql_user,$mysql_password);
if($conn)
if(@mysqli_select_db($conn,'login1'))
else
else
die('connection error');
if($get)
else
?>
Output:
A web application that lists all cookies stored in the browser on clicking “List
Cookies” button. Add cookies if necessary.
Source Code:
setCookies.php
<html>
<head>
</head>
<center>
<?php
setcookie('Cookie_1','Cookie_1_Value',time() + 86400);
setcookie('Cookie_2',"Cookie_2_Value",time() + 86400);
?>
</center>
</body>
</html>
listCookies.php
<html>
<head>
<body bgcolor="#81d6b1">
<center>
<h1>Cookies Are:</h1>
<br><br>
<br><br>
<br><br>
</form>
</center>
<?php
error_reporting(0);
if($_POST['list'])
foreach($_COOKIE as $key=>$val)
</center>";
?>
</body>
</html>
Output:
Lead 1:
Write a program to check whether the given number is Armstrong number or not
using PHP Script
Source Code:
Arm.php
<html>
<head>
</head>
<body>
<center>
<table>
<tr>
<td>Number:</td>
</tr>
<tr>
</td>
</tr>
</table>
</form>
<br>
<?php
if(isset($_POST['Submit'])){
$num=$_POST['num'];
if($num<0)
else{
$s=0;
$temp=$num;
$c=0;
$temp1=$temp;
while($temp1>0){
$c++;
$temp1=intdiv($temp1,10);
while($temp>0){
$x=$temp%10;
$s+=$x**$c;
$temp=intdiv($temp,10);
if($num==$s)
echo "<h3><b>Given Number ".$num." is a Armstrong Number</b></h3>";
else
} }
?>
</center>
</body>
</html>
Output:
Lead2:
Write a program to print Fibonacci Series using PHP Script
Source Code:
Fib.php
<html>
<head>
<title>Fibonacci Generator</title>
</head>
<body>
<center>
<table>
<tr>
<td>First Number:</td>
</tr>
<tr>
<td>Second Number:</td>
</tr>
<tr>
<td>Series Length:</td>
</tr>
<tr>
</td>
</tr>
</table>
</form>
<br>
<?php
if(isset($_POST['Submit'])){
$num1=$_POST['num1'];
$num2=$_POST['num2'];
$n=$_POST['n'];
for($i=0;$i<$n;$i++){
$tp=$num2;
$num2=$num1+$num2;
$num1=$tp;
?>
</center>
</body>
</html>
Output: