SlideShare a Scribd company logo
Week 1:
To create a simple student bio-data form using html5 . it shouldcontain the following name (text box),
address (multiline text box),gender (radio button male,female),skill sets known (check boxes –
c,c++,java,C#etc), extra-curricular activities (text box), nationality (combobox) ,submit and reset button.
Program:
Reg.html
<html>
<head>
<title>Student Registration Form</title>
<script type="text/javascript" src="validate.js"></script>
</head>
<body>
<table cellpadding="2" width="20%" bgcolor="99FFFF" align="center" cellspacing="2">
<tr>
<td colspan=2>
<center>
<font size=4>
<b>Student Registration Form</b>
</font>
</center>
</td>
</tr>
<tr>
<td>Name</td>
<td>
<input type="text" name="studentname" id="studentname" size="30">
</td>
</tr>
<tr>
<td>Father Name</td>
<td>
<input type="text" name="fathername" id="fathername" size="30">
</td>
</tr>
<tr>
<td>Postal Address</td>
<td>
<input type="text" name="paddress" id="paddress" size="30">
</td>
</tr>
<tr>
<td>Personal Address</td>
<td>
<input type="text" name="praddress" id="praddress" size="30">
</td>
</tr>
<tr>
<td>Sex</td>
<td>
<input type="radio" name="sex" value="male" size="10">Male
<input type="radio" name="sex" value="Female" size="10">Female
</td>
</tr>
<tr>
<td>City</td>
<td>
<select name="City">
<option value="-1" selected>select..</option>
<option value="New Delhi">NEW DELHI</option>
<option value="Mumbai">MUMBAI</option>
<option value="Goa">GOA</option>
<option value="Patna">PATNA</option>
</select></td>
</tr>
<tr>
<td>Course</td>
<td><select name="Course">
<option value="-1" selected>select..</option>
<option value="B.Tech">B.TECH</option>
<option value="MCA">MCA</option>
<option value="MBA">MBA</option>
<option value="BCA">BCA</option>
</select></td>
</tr>
<tr>
<td>District</td>
<td><select name="District">
<option value="-1" selected>select..</option>
<option value="Nalanda">NALANDA</option>
<option value="UP">UP</option>
<option value="Goa">GOA</option>
<option value="Patna">PATNA</option>
</select></td>
</tr>
<tr>
<td>State</td>
<td><select Name="State">
<option value="-1" selected>select..</option>
<option value="New Delhi">NEW DELHI</option>
<option value="Mumbai">MUMBAI</option>
<option value="Goa">GOA</option>
<option value="Bihar">BIHAR</option>
</select></td>
</tr>
<tr>
<td>PinCode</td>
<td><input type="text" name="pincode" id="pincode" size="30"></td>
</tr>
<tr>
<td>EmailId</td>
<td><input type="text" name="emailid" id="emailid" size="30"></td>
</tr>
<tr>
<td>DOB</td>
<td><input type="text" name="dob" id="dob" size="30"></td>
</tr>
<tr>
<td>MobileNo</td>
<td><input type="text" name="mobileno" id="mobileno" size="30"></td>
</tr>
<tr>
<td>
<input type="reset">
</td>
<td colspan="2">
<input type="submit" value="Submit Form" />
</td>
</tr>
</table>
</body>
</html>
output
Week 2:
To create an html page with differenttypes of frames such as floating frame, navigationframe &
mixed frame
Program:
Mainpage.html
<html>
<body>
<a href="frames.html" target="two">navigation frame</a><br>
<a href="floatingframe.html" target="two">floating frame</a><br>
<a href="Noframe.html" target="two">no frame</a><br>
<a href="mixedframe.html" target="two">mixed frame</a><br>
</body>
</html>
Frame.html
<html>
<frameset cols="20%,35%,*" scrolling="no" noresize>
<frame name="one" src="MainPage.html"></frame>
<frame src="aa.gif"></frame>
<frame name="two" src="hulk.gif"></frame>
</frameset>
</html>
Floatingframe.html
<html>
<body>
<p> Explanation: There is a problem with the page you are trying to reach and it
cannot be displayed. Try the following:
* Refresh page: Search for the page again by clicking the Refresh button. The timeout may have
occurred due to Internet congestion.
* Check spelling: Check that you typed the Web page address correctly. The
address may have been mistyped.
* Access from a link: If there is a link to the page you are looking for, try accessing
the page from that link.
If you are still not able to view the requested page, try contacting you
<iframe src="bb.gif" height="225" width="500">
</iframe>
<iframe src="MainPage.html" height="50%" width="50%">
</iframe>
</body>
</html>
Mixedframe.html
<html>
<frameset cols="30%,*">
<frame src="pic.html"></frame>
<frameset rows="50%,*">
<frame src="video.html" autostart="true">
<frame src="Q3.html" >
</frameset>
</frameset>
</html>
navigationframe.html
<html>
<frameset cols="25%,*" scrolling="no" noresize>
<frame name="one" src="MainPage.html">
</frame>
<frame name="two" ></frame>
<frameset rows="30%,*">
<frame src="hulk.gif">
</frame>
</frameset>
</html>
pic.html
<html>
<body>
<img src="ghanendra.jpg" height="650" width="400">
</body>
</html>
video.html
<html>
<body bgcolor="aqua">
<embed src="aa.mp4" width="600" height="300" autostart="true">
</embed>
</body>
</html>
Week 3:
Design the webpageby applying the differentstyles using inline, external & internal style sheets.
Program:
Inline.html:
<html>
<head>
<title>Example of HTML Inline Styles</title>
</head>
<body>
<h1 style="color:red;font-size:30px;">This is a heading</h1>
<p style="color:green;font-size:18px;">This is a paragraph.</p>
<hr style="border-color:blue;">
</body>
</html>
Internal.html:
<html>
<head>
<title>Example of HTML Embedded Style Sheet</title>
<style type="text/css">
body { background-color: YellowGreen; }
h1 { color: red; }
p { color: green; }
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
External Style Sheet(link & import)
link.html:
<html>
<head>
<title>Example of HTML External Style Sheet</title>
<link rel="stylesheet" type="text/css" href=" style.css">
</head>
<body>
<h1>Linking External Style Sheet</h1>
<p>The styles of this HTML document are defined in linked style sheet.</p>
</body>
</html>
import.html:
<html>
<head>
<meta charset="UTF-8">
<title>Example of CSS @import rule</title>
<style type="text/css">
@import url("/examples/css/style.css");
body {
color:blue;
font-size:14px;
}
</style>
</head>
<body>
<div>
<h1>Importing External Style Sheet</h1>
<p>The layout styles of dese HTML element is dfnd in style.css'.</p>
</div>
</body>
</html>
Style.css:
body {
background-color: powderblue;
}
h1 {
color: blue;
}
p {
color: red;
}
main.html
<html>
<body>
<h2><a href="inline.html">inline style</a></h2>
<h2><a href="internal.html">internal style</a></h2>
<h2><a href="link.html">link style</a></h2>
<h2><a href="import.html">import style</a></h2>
</body>
</html>
output
week 4:
Write a java script program to read .XML file and display data in a neat format.
The XMLFile
You can open libbhanu.xml file to view it. Copy the contents of the file and save it in your
computer and name it as library.xml, because we are using the same file name in our example.
You can change the name of the file according to your choice later.
ExtractData from XML
After creating the XML file (also called XML document), we will write JavaScript to read and
extract data from the file. The HTML DIV element is a lightweight container, so we decided to
use a DIV element to display the XML data on our web page.
Tabular format
We want to display data in a tabular format with couple of columns. The columns will show
the Bookname and Category respectively.
To show data in tabular formats (i.e. in two columns), we need to use two more DIV elements
inside the main DIV, which serves as a container. We will use CSS to place both the DIV
elements side-by-side.
libbhanu.xml :
<Library>
<List>
<code>1</code>
<BookName>Computer Architecture</BookName>
<Category>Computers</Category>
<Price>125.60</Price>
</List>
<List>
<code>2</code>
<BookName>Advanced Composite Materials</BookName>
<Category>Science</Category>
<Price>172.56</Price>
</List>
<List>
<code>3</code>
<BookName>Asp.Net 4 Blue Book</BookName>
<Category>Programming</Category>
<Price>56.00</Price>
</List>
<List>
<code>4</code>
<BookName>Stategies Unplugged</BookName>
<Category>Science</Category>
<Price>99.99</Price>
</List>
<List>
<code>5</code>
<BookName>Teaching Science</BookName>
<Category>Science</Category>
<Price>164.10</Price>
</List>
<List>
<code>6</code>
<BookName>Challenging Times</BookName>
<Category>Business</Category>
<Price>150.70</Price>
</List>
<List>
<code>7</code>
<BookName>Circuit Bending</BookName>
<Category>Science</Category>
<Price>112.00</Price>
</List>
<List>
<code>8</code>
<BookName>Popular Science</BookName>
<Category>Science</Category>
<Price>210.40</Price>
</List>
<List>
<code>9</code>
<BookName>ADOBE Premiere</BookName>
<Category>Computers</Category>
<Price>62.20</Price>
</List>
</Library>
extract.html:
<html>
<head>
<title>Extract XML Data using JavaScript</title>
<style>
#books {
font:13px Arial;
width:390px;
text-align:center;
border:solid 1px #000;
overflow:hidden;
}
#books div {
width:180px;
text-align:left;
border:solid 1px #000;
margin:1px;
padding:2px 5px;
}
.col1 {
float:left;
clear:both;
}
.col2 {
float:right;
}
</style>
</head>
<body>
<div id="books"></div>
</body>
<script>
var oXHR = window.XMLHttpRequest ? new XMLHttpRequest() : new
ActiveXObject('Microsoft.XMLHTTP');
function reportStatus() {
if (oXHR.readyState == 4) // REQUEST COMPLETED.
showTheList(this.responseXML); // ALL SET. NOW SHOW XML DATA.
}
oXHR.onreadystatechange = reportStatus;
oXHR.open("GET", "libbhanu.xml", true); // true = ASYNCHRONOUS REQUEST
(DESIRABLE), false = SYNCHRONOUS REQUEST.
oXHR.send();
function showTheList(xml)
{
var divBooks = document.getElementById('books'); // THE PARENT DIV.
var Book_List = xml.getElementsByTagName('List'); // THE XML TAG NAME.
for (var i = 0; i < Book_List.length; i++) {
// CREATE CHILD DIVS INSIDE THE PARENT DIV.
var divLeft = document.createElement('div');
divLeft.className = 'col1';
divLeft.innerHTML =
Book_List[i].getElementsByTagName("BookName")[0].childNodes[0].nodeValue;
var divRight = document.createElement('div');
divRight.className = 'col2';
divRight.innerHTML =
Book_List[i].getElementsByTagName("Category")[0].childNodes[0].nodeValue;
// ADD THE CHILD TO THE PARENT DIV.
divBooks.appendChild(divLeft);
divBooks.appendChild(divRight);
}
};
</script>
</html>
output
Week 5:
To write a Javascriptprogramto define a user defined function for sorting the values in an
array. Use HTML5 for user interface.
<html>
<body>
<h1>My First JavaScript</h1>
<p>JavaScript can change the content of an HTML element:</p>
<button type="button" onclick="myFunction()">Click Me!</button>
<p id="demo">This is a demonstration.</p>
<script>
function myFunction() {
var fruits = ['apple', 'orange', 'banana'];
var numbers = [10, 20, 2, 3, 0, 500];
for(var i =0;i<numbers.length;i++){
for(var j= i+1;j<numbers.length;j++){
if(numbers[i]>numbers[j]){
var swap = numbers[i];
numbers[i] = numbers[j];
numbers[j] = swap;
}
}
}
show_array(fruits);
show_array(numbers);
}
function show_array(array) {
var text = '';
for(var i in array) {
text += array[i];
text += 'n';
}
alert(text);
}
</script>
</body>
</html>
Dynamic reading of variables from textbox and sorting:
<html>
<head>
<script type="text/javascript">
<!--
function RunTest()
{
var a= document.forms[0].elements[0].value;
try {
alert("Value of variable a is : " + a );
}
catch ( e ) {
alert("Error: " + e.description );
}
}
//-->
</script>
</head>
<body>
<p>Click the following to see the result:</p>
<form>
<input type="text" name="txtJob" id="txtJob" >
<input type="button" value="Click Me" onclick="RunTest();"
</form>
</body>
</html>
Output1
After clicking the Clickme button,
Week 6:
To create an html page to demonstrate exception handling in javascript
Create an html page named as ―exception.html‖ and do the following.
i. within the script tag write code to handle exception
a) define a method RunTest() to get any string values(str) from the user and call the
method Areletters(str).
b) In Areletters(str) method check whether str contain only alphabets (a-z, A-Z), if
not throw exception.
c) Define a exception method Input Exception(str) to handle the exception thrown
by the above method.
ii. Within the body tag define a script tag to call Runtest() method define.
<html>
<body>
Enter the data
<input id="demo" type="text">
<button type="button" onclick="RunTest()">Test Input</button>
<p id="message"></p>
<script type="text/javascript">
function RunTest()
{
var message, x,y;
message = document.getElementById("message");
message.innerHTML = " ";
x = document.getElementById("demo");
try {
alert(x);
var letters = /^[A-Za-z]+$/;
y=x.value.match(letters);
if(y)
document.writeln("this string is accepted");
else
throw "not a string";
}
catch(err) {
message.innerHTML = "Input is " + err;
}
}
</script>
</body>
</html>
Output:
After Entering the values in the text box, it it is String ,it is accepted.otherwise it shows as error.
Week 7
Write a jsp servlet program to implement the single text field calculator.
One.html
<html>
<body>
<form method=”get” action=”./CalculateServlet”>
Number 1 : <input type=”text” name=”no1″> <br>
Number 2 : <input type=”text” name=”no2″> <br>
Operator :
<select name=”opt”>
<option value=”p”> + </option>
<option value=”m”> – </option>
<option value=”mul”> * </option>
<option value=”d”> / </option>
</select>
<br>
<input type=”submit” value=”Go”>
</form>
</body>
</html>
File: CalculateServlet.java
import java.io.*;
import javax.servlet.*;
//import javax.servlet.http.*;
public class CalculateServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response) throws
IOException,ServletException
{
display();
PrintWriter out = response.getWriter();
//out.println(“hello”);
String n1 = request.getParameter(“no1”);
String n2 = request.getParameter(“no2”);
String opt = request.getParameter(“opt”);
if(opt.equals(“p”))
out.println(Integer.parseInt(n1) + Integer.parseInt(n2));
else if(opt.equals(“m”))
out.println(Integer.parseInt(n1) – Integer.parseInt(n2));
}
public void doGet(HttpServletRequest request,HttpServletResponse response) throws
IOException,ServletException
{
doPost(request,response);
}
}
File : web.xml
<web-app>
<servlet>
<servlet-name>CalculateServlet</servlet-name>
<servlet-class>CalculateServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CalculateServlet</servlet-name>
<url-pattern>/CalculateServlet</url-pattern>
</servlet-mapping>
</web-app>
Output
After entering the values,based on the selection of operation,the result will be displayed on the
browser.
Week 8
Write a jsp servlet program to demonstrate session handling using
 url rewriting
 hidden formfield
 cookies
 sessions
login.html
<!DOCTYPE html>
<html>
<head>
<meta charset="US-ASCII">
<title>Login Page</title>
</head>
<body>
<form action="LoginServlet" method="post">
Username: <input type="text" name="user">
<br>
Password: <input type="password" name="pwd">
<br>
<input type="submit" value="Login">
</form>
</body>
</html>
LoginSuccess.jsp
<%@ page language="java"
contentType="text/html;
charset=US-ASCII"
pageEncoding="US-ASCII"%>
<!DOCTYPE html PUBLIC "-
//W3C//DTD HTML 4.01
Transitional//EN"
"http://www.w3.org/TR/html4/loos
e.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=US-
ASCII">
<title>Login Success Page</title>
</head>
<body>
<%
//allow access only if session exists
String user = null;
if(session.getAttribute("user") ==
null){
response.sendRedirect("login.
html");
}else user = (String)
session.getAttribute("user");
String userName = null;
String sessionID = null;
Cookie[] cookies =
request.getCookies();
if(cookies !=null){
for(Cookie cookie : cookies){
if(cookie.getName().equals("u
ser")) userName =
cookie.getValue();
if(cookie.getName().equals("J
SESSIONID")) sessionID =
cookie.getValue();
}
}
%>
<h3>Hi <%=userName %>, Login
successful. Your Session
ID=<%=sessionID %></h3>
<br>
User=<%=user %>
<br>
<a
href="CheckoutPage.jsp">Checkou
t Page</a>
<form action="LogoutServlet"
method="post">
<input type="submit"
value="Logout" >
</form>
</body>
</html>
CheckoutPage.jsp
<%@ page language="java"
contentType="text/html; charset=US-ASCII"
pageEncoding="US-ASCII"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD
HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=US-ASCII">
<title>Login Success Page</title>
</head>
<body>
<%
//allow access only if session exists
if(session.getAttribute("user") == null){
response.sendRedirect("login.html");
}
String userName = null;
String sessionID = null;
Cookie[] cookies = request.getCookies();
if(cookies !=null){
for(Cookie cookie : cookies){
if(cookie.getName().equals("user"))
userName = cookie.getValue();
}
}
%>
<h3>Hi <%=userName %>, do the
checkout.</h3>
<br>
<form action="LogoutServlet"
method="post">
<input type="submit" value="Logout" >
</form>
</body>
</html>
output
For More Programs visit:
https://www.journaldev.com/1907/java-session-management-servlet-httpsession-url-rewriting
week 9:
To create a php program to demonstrate the different predefined function in array,
Math, Data & Regular Expression.
Procedure:
Create php file named as Regularexpression.php
for demonstrating the method for handling various strings with regular expression
Array.php
for demonstrating the methods for handling the array values Math_function.php
to demonstrate the predefined in math objects. Date_time.php to demonstrate the
predefined function in date subject.
week 10:
Write a program in PHP for a simple email processing with attachment using forms
One.html
<form method="POST" name="email_form_with_php"
action="php-form-action.php" enctype="multipart/form-data">
<label for='name'>Name: </label>
<input type="text" name="name" >
<label for='email'>Email: </label>
<input type="text" name="email" >
<label for='message'>Message:</label>
<textarea name="message"></textarea>
<label for='uploaded_file'>Select A File To Upload:</label>
<input type="file" name="uploaded_file">
<input type="submit" value="Submit" name='submit'>
</form>
Send-email-form.php
<?php
// Pear library includes
// You should have the pear lib installed
include_once('Mail.php');
include_once('Mail_Mime/mime.php');
//Settings
$max_allowed_file_size = 100; // size in KB
$allowed_extensions = array("jpg", "jpeg", "gif", "bmp");
$upload_folder = './uploads/'; //<-- this folder must be writeable by the script
$your_email = 'tom@amazing-designs.com';//<<-- update this to your email address
$errors ='';
if(isset($_POST['submit']))
{
//Get the uploaded file information
$name_of_uploaded_file = basename($_FILES['uploaded_file']['name']);
//get the file extension of the file
$type_of_uploaded_file = substr($name_of_uploaded_file,
strrpos($name_of_uploaded_file, '.') + 1);
$size_of_uploaded_file = $_FILES["uploaded_file"]["size"]/1024;
///------------Do Validations-------------
if(empty($_POST['name'])||empty($_POST['email']))
{
$errors .= "n Name and Email are required fields. ";
}
if(IsInjected($visitor_email))
{
$errors .= "n Bad email value!";
}
if($size_of_uploaded_file > $max_allowed_file_size )
{
$errors .= "n Size of file should be less than $max_allowed_file_size";
}
//------ Validate the file extension -----
$allowed_ext = false;
for($i=0; $i<sizeof($allowed_extensions); $i++)
{
if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0)
{
$allowed_ext = true;
}
}
if(!$allowed_ext)
{
$errors .= "n The uploaded file is not supported file type. ".
" Only the following file types are supported:
".implode(',',$allowed_extensions);
}
//send the email
if(empty($errors))
{
//copy the temp. uploaded file to uploads folder
$path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;
$tmp_path = $_FILES["uploaded_file"]["tmp_name"];
if(is_uploaded_file($tmp_path))
{
if(!copy($tmp_path,$path_of_uploaded_file))
{
$errors .= 'n error while copying the uploaded file';
}
}
//send the email
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$user_message = $_POST['message'];
$to = $your_email;
$subject="New form submission";
$from = $your_email;
$text = "A user $name has sent you this message:n $user_message";
$message = new Mail_mime();
$message->setTXTBody($text);
$message->addAttachment($path_of_uploaded_file);
$body = $message->get();
$extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-
To"=>$visitor_email);
$headers = $message->headers($extraheaders);
$mail = Mail::factory("mail");
$mail->send($to, $headers, $body);
//redirect to 'thank-you page
header('Location: thank-you.html');
}
}
///////////////////////////Functions/////////////////
// Function to validate against any email injection attempts
function IsInjected($str)
{
$injections = array('(n+)',
'(r+)',
'(t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str))
{
return true;
}
else
{
return false;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>File upload form</title>
<!-- define some style elements-->
<style>
label,a, body
{
font-family : Arial, Helvetica, sans-serif;
font-size : 12px;
}
</style>
<!-- a helper script for vaidating the form-->
<script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script>
</head>
<body>
<?php
if(!empty($errors))
{
echo nl2br($errors);
}
?>
<form method="POST" name="email_form_with_php"
action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-
data">
<p>
<label for='name'>Name: </label><br>
<input type="text" name="name" >
</p>
<p>
<label for='email'>Email: </label><br>
<input type="text" name="email" >
</p>
<p>
<label for='message'>Message:</label> <br>
<textarea name="message"></textarea>
</p>
<p>
<label for='uploaded_file'>Select A File To Upload:</label> <br>
<input type="file" name="uploaded_file">
</p>
<input type="submit" value="Submit" name='submit'>
</form>
<script language="JavaScript">
// Code for validating the form
// Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
// for details
var frmvalidator = new Validator("email_form_with_php");
frmvalidator.addValidation("name","req","Please provide your name");
frmvalidator.addValidation("email","req","Please provide your email");
frmvalidator.addValidation("email","email","Please enter a valid email address");
</script>
<noscript>
<small><a href='http://www.html-form-guide.com/email-form/php-email-form-attachment.html'
>How to attach file to email in PHP</a> article page.</small>
</noscript>
</body>
</html>
output
Week 11
Write a program for PHP for a login script ; create a login database and store
username and password
One.html
form action="" method="post" id="frmLogin">
<div class="error-message"><?php if(isset($message)) { echo $message; }
?></div>
<div class="field-group">
<div><label for="login">Username</label></div>
<div><input name="user_name" type="text" class="input-field"></div>
</div>
<div class="field-group">
<div><label for="password">Password</label></div>
<div><input name="password" type="password" class="input-field">
</div>
</div>
<div class="field-group">
<div><input type="submit" name="login" value="Login" class="form-
submit-button"></span></div>
</div>
</form>
Login.php
<?php
session_start();
$conn = mysqli_connect("localhost","root","","phppot_examples");
$message="";
if(!empty($_POST["login"])) {
$result = mysqli_query($conn,"SELECT * FROM users WHERE user_name='" .
$_POST["user_name"] . "' and password = '". $_POST["password"]."'");
$row = mysqli_fetch_array($result);
if(is_array($row)) {
$_SESSION["user_id"] = $row['user_id'];
} else {
$message = "Invalid Username or Password!";
}
}
?>
Login1.php
<?php
} else {
$result = mysqlI_query($conn,"SELECT * FROM users WHERE user_id='" .
$_SESSION["phppot_demopage_459_user_id"] . "'");
$row = mysqli_fetch_array($result);
?>
<form action="" method="post" id="frmLogout">
<div class="member-dashboard">Welcome <?php echo
ucwords($row['display_name']); ?>, You have successfully logged in!<br>
Click to <input type="submit" name="logout" value="Logout" class="logout-
button">.</div>
</form>
</div>
</div>
<?php } ?>
Logout.php
<?php
if(!empty($_POST["logout"])) {
$_SESSION["user_id"] = "";
session_destroy();
}
?>
output
Week 12
Write a program in PHP to add, update and delete using student database
Insert data
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
Delete data
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// sql to delete a record
$sql = "DELETE FROM MyGuests WHERE id=3";
if ($conn->query($sql) === TRUE) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . $conn->error;
}
$conn->close();
?>
Update data
?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>
Output:
New record created successfully
Record deleted successfully
Record updated successfully
Week 13
Create a DTD to describe a library. Library has one or more books, members and staffs.
Each book has BookID(Attribute), Title, one or more Authors, Publisher Year of
Publication, ISBN and Price.
Each Member has MemeberID(Attribute), Name, Address, Phone number.
Each Staff has StaffID(Attribute), Name, Address, Phone number.
Each Author has AuthorID(Attribute), Name, Address, Phone number.
Each Publisher has PublisherID(Attribute), Name, Address, Phone number.
Use it in a XML document.
libbhanu.xml :
<Library>
<List>
<code>1</code>
<BookName>Computer Architecture</BookName>
<Category>Computers</Category>
<Price>125.60</Price>
</List>
<List>
<code>2</code>
<BookName>Advanced Composite Materials</BookName>
<Category>Science</Category>
<Price>172.56</Price>
</List>
<List>
<code>3</code>
<BookName>Asp.Net 4 Blue Book</BookName>
<Category>Programming</Category>
<Price>56.00</Price>
</List>
<List>
<code>4</code>
<BookName>Stategies Unplugged</BookName>
<Category>Science</Category>
<Price>99.99</Price>
</List>
<List>
<code>5</code>
<BookName>Teaching Science</BookName>
<Category>Science</Category>
<Price>164.10</Price>
</List>
<List>
<code>6</code>
<BookName>Challenging Times</BookName>
<Category>Business</Category>
<Price>150.70</Price>
</List>
<List>
<code>7</code>
<BookName>Circuit Bending</BookName>
<Category>Science</Category>
<Price>112.00</Price>
</List>
<List>
<code>8</code>
<BookName>Popular Science</BookName>
<Category>Science</Category>
<Price>210.40</Price>
</List>
<List>
<code>9</code>
<BookName>ADOBE Premiere</BookName>
<Category>Computers</Category>
<Price>62.20</Price>
</List>
</Library>
extract.html:
<html>
<head>
<title>Extract XML Data using JavaScript</title>
<style>
#books {
font:13px Arial;
width:390px;
text-align:center;
border:solid 1px #000;
overflow:hidden;
}
#books div {
width:180px;
text-align:left;
border:solid 1px #000;
margin:1px;
padding:2px 5px;
}
.col1 {
float:left;
clear:both;
}
.col2 {
float:right;
}
</style>
</head>
<body>
<div id="books"></div>
</body>
<script>
var oXHR = window.XMLHttpRequest ? new XMLHttpRequest() : new
ActiveXObject('Microsoft.XMLHTTP');
function reportStatus() {
if (oXHR.readyState == 4) // REQUEST COMPLETED.
showTheList(this.responseXML); // ALL SET. NOW SHOW XML DATA.
}
oXHR.onreadystatechange = reportStatus;
oXHR.open("GET", "libbhanu.xml", true); // true = ASYNCHRONOUS REQUEST
(DESIRABLE), false = SYNCHRONOUS REQUEST.
oXHR.send();
function showTheList(xml)
{
var divBooks = document.getElementById('books'); // THE PARENT DIV.
var Book_List = xml.getElementsByTagName('List'); // THE XML TAG NAME.
for (var i = 0; i < Book_List.length; i++) {
// CREATE CHILD DIVS INSIDE THE PARENT DIV.
var divLeft = document.createElement('div');
divLeft.className = 'col1';
divLeft.innerHTML =
Book_List[i].getElementsByTagName("BookName")[0].childNodes[0].nodeValue;
var divRight = document.createElement('div');
divRight.className = 'col2';
divRight.innerHTML =
Book_List[i].getElementsByTagName("Category")[0].childNodes[0].nodeValue;
// ADD THE CHILD TO THE PARENT DIV.
divBooks.appendChild(divLeft);
divBooks.appendChild(divRight);
}
};
</script>
</html>
output
Week14:
Create a DTD to describe a Computer.A computer has following details,
 Type of computer (this is an attribute), Which can be Desktop PC, Laptop,Palm Top, Server,
Minicomputer or mainframe)
 A Monitor with Serial Number (Attribute), Make, Model, Year of manufacture,Size, Type
(which is either colour or monochrome)
 A keyboard with Serial Number (Attribute), Make, Model, Year of manufacture,No of keys,
Type( which is either Standard or Enhanced or Multimedia)
 A mouse with Serial Number (Attribute), Make, Model, Year of manufacture,No of buttons,
Scroll wheel (which is yes or no), Type (Which is Ball or Optical
 A Mother board with Serial Number (Attribute),Make,Model,Year ofmanufacture, No of USB
ports, No of IDE slots, No of SATA hubs, No of PCIslots, Display Type(Which is VGA or HDMI),
Number of Processor slots, Typeof Processors supported (must be a list), Type of RAM
supported (Which iseither SD or DDR1 or DDR2 or RD), Maximum Capacity of RAM, Form
Factor(which is either AT or Baby AT), On Board sound card (Which is yes or no)
 A Microprocessor with Serial Number (Attribute), Make, Model, Year ofmanufacture, speed
(in GHz), No of Cores (Single, Dual, Quad)
 A power supply with Serial Number (Attribute), Make, Model, Year ofmanufacture, Type (AT,
ATX), Wattage One or more hard disks, each Hard disk must have Serial Number (Attribute),
 Make, Model, Year of manufacture, capacity and type (Which is IDE or SATAIor SATAII, SCSI)
One or more RAM SIMM, with Serial Number (Attribute), Make, Model, Year of manufacture,
Type (which must be SD, DDRI, DDRII, RD), capacity, operating frequency.
Use it in a XML document.
Week 15:
Create a Schema to describe a Computer. Use the previous question‘s details and
show an instance XML document
Week 16:
Create a Schema to describe a library. Library has one or more - books, members
and staffs.
 Each book has BookID(Attribute), Title, one or more Authors, Publisher Year
of Publication, ISBN and Price.
 Each Member has MemeberID(Attribute), Name, Address, Phone number.
 Each Staff has StaffID(Attribute), Name, Address, Phone number.
 Each Author has AuthorID(Attribute), Name, Address, Phone number.
 Each Publisher has PublisherID(Attribute), Name, Address, Phone number.
 Use the above DTD in a sample XML document.
book.dtd
<!ELEMENT bookdetails (books+)>
<!ELEMENT books (title,author,edition,price)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT edition (#PCDATA)>
<!ELEMENT price (#PCDATA)>
book.xml
<?xml version="1.0"?>
<!DOCTYPE bookdetails SYSTEM "book.dtd">
<?xml:stylesheet type="text/xsl" href="book.xsl"?>
<bookdetails>
<books>
<title> C </title>
<author> Balaguruswamy </author>
<edition> Edition-II </edition>
<price>$30.00</price>
</books>
<books>
<title> C++ </title>
<author> yaswanth kanethkar </author>
<edition> Edition-I </edition>
<price>$35.00</price>
</books>
<books>
<title> JAVA </title>
<author> Herbert Schildt </author>
<edition> Edition-IV </edition>
<price>$50.00</price>
</books>
</bookdetails>
book.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head> <center>Book Details</center> </head>
<body>
<hr width="50%"/>
<table border="1" align="center">
<tr>
<th> TITLE </th>
<th> AUTHOR </th>
<th> EDITON </th>
<th> PRICE </th>
</tr>
<xsl:for-each select="bookdetails/books">
<tr>
<td> <xsl:value-of select="title"/></td>
<td> <xsl:value-of select="author"/></td>
<td> <xsl:value-of select="edition"/></td>
<td> <xsl:value-of select="price"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Result:-
Week 17:
Create a DTD to describe a bank that has one or more customers, accounts or
Employee.
 Each Customerhas a CustomerID, Name and address.
 Each account has an account ID, BranchID, CustomerID,AccountTypeand Balance.
 Each Employee has aEmpID, Name,Designation,DOJ, Salary and
Address.
Use this DTD in a XML file.
Week 18:
Create Schema describe a bank that has one or more customers, accounts or depositors.Use the
previousquestionsdetails.Alsoshow a sample instance XML document

More Related Content

Similar to WIT lab programs.docx

html for beginners
html for beginnershtml for beginners
html for beginners
KIIZAPHILIP
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
www.netgains.org
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to Bootstrap
Ron Reiter
 
The complete-html-cheat-sheet
The complete-html-cheat-sheetThe complete-html-cheat-sheet
The complete-html-cheat-sheet
HARUN PEHLIVAN
 
The complete-html-cheat-sheet
The complete-html-cheat-sheetThe complete-html-cheat-sheet
The complete-html-cheat-sheet
Zafer Galip Ozberk
 
Please help with creating a javascript file to produce the outcome bel.pdf
Please help with creating a javascript file to produce the outcome bel.pdfPlease help with creating a javascript file to produce the outcome bel.pdf
Please help with creating a javascript file to produce the outcome bel.pdf
info750646
 
Please help with creating a javascript file to produce the outcome bel (1).pdf
Please help with creating a javascript file to produce the outcome bel (1).pdfPlease help with creating a javascript file to produce the outcome bel (1).pdf
Please help with creating a javascript file to produce the outcome bel (1).pdf
pankajsingh316693
 
ViA Bootstrap 4
ViA Bootstrap 4ViA Bootstrap 4
ViA Bootstrap 4
imdurgesh
 
Bootstrap
BootstrapBootstrap
Bootstrap
Sarvesh Kushwaha
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
Shawn Calvert
 
Caracteristicas Basicas De Htlm
Caracteristicas Basicas De HtlmCaracteristicas Basicas De Htlm
Caracteristicas Basicas De Htlm
Maria S Rivera
 
Polymer 1.0
Polymer 1.0Polymer 1.0
Polymer 1.0
Cyril Balit
 
Bootstrap 3
Bootstrap 3Bootstrap 3
Bootstrap 3
McSoftsis
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
Kyle Cearley
 
DIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningDIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web Designing
Rasan Samarasinghe
 
Bootstrap PPT by Mukesh
Bootstrap PPT by MukeshBootstrap PPT by Mukesh
Bootstrap PPT by Mukesh
Mukesh Kumar
 
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular U
Joonas Lehtinen
 
asp.net - for merge.docx
asp.net - for merge.docxasp.net - for merge.docx
asp.net - for merge.docx
SwapnilGujar13
 
Template-based Modular Architecture
Template-based Modular ArchitectureTemplate-based Modular Architecture
Template-based Modular Architecture
genify
 

Similar to WIT lab programs.docx (20)

html for beginners
html for beginnershtml for beginners
html for beginners
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to Bootstrap
 
The complete-html-cheat-sheet
The complete-html-cheat-sheetThe complete-html-cheat-sheet
The complete-html-cheat-sheet
 
The complete-html-cheat-sheet
The complete-html-cheat-sheetThe complete-html-cheat-sheet
The complete-html-cheat-sheet
 
Please help with creating a javascript file to produce the outcome bel.pdf
Please help with creating a javascript file to produce the outcome bel.pdfPlease help with creating a javascript file to produce the outcome bel.pdf
Please help with creating a javascript file to produce the outcome bel.pdf
 
Please help with creating a javascript file to produce the outcome bel (1).pdf
Please help with creating a javascript file to produce the outcome bel (1).pdfPlease help with creating a javascript file to produce the outcome bel (1).pdf
Please help with creating a javascript file to produce the outcome bel (1).pdf
 
ViA Bootstrap 4
ViA Bootstrap 4ViA Bootstrap 4
ViA Bootstrap 4
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
Caracteristicas Basicas De Htlm
Caracteristicas Basicas De HtlmCaracteristicas Basicas De Htlm
Caracteristicas Basicas De Htlm
 
Polymer 1.0
Polymer 1.0Polymer 1.0
Polymer 1.0
 
Bootstrap 3
Bootstrap 3Bootstrap 3
Bootstrap 3
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
DIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningDIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web Designing
 
Bootstrap PPT by Mukesh
Bootstrap PPT by MukeshBootstrap PPT by Mukesh
Bootstrap PPT by Mukesh
 
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
 
Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular U
 
asp.net - for merge.docx
asp.net - for merge.docxasp.net - for merge.docx
asp.net - for merge.docx
 
Template-based Modular Architecture
Template-based Modular ArchitectureTemplate-based Modular Architecture
Template-based Modular Architecture
 

Recently uploaded

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 

Recently uploaded (20)

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 

WIT lab programs.docx

  • 1. Week 1: To create a simple student bio-data form using html5 . it shouldcontain the following name (text box), address (multiline text box),gender (radio button male,female),skill sets known (check boxes – c,c++,java,C#etc), extra-curricular activities (text box), nationality (combobox) ,submit and reset button. Program: Reg.html <html> <head> <title>Student Registration Form</title> <script type="text/javascript" src="validate.js"></script> </head> <body> <table cellpadding="2" width="20%" bgcolor="99FFFF" align="center" cellspacing="2"> <tr> <td colspan=2> <center> <font size=4> <b>Student Registration Form</b> </font> </center> </td> </tr> <tr> <td>Name</td> <td> <input type="text" name="studentname" id="studentname" size="30"> </td> </tr> <tr> <td>Father Name</td> <td> <input type="text" name="fathername" id="fathername" size="30"> </td>
  • 2. </tr> <tr> <td>Postal Address</td> <td> <input type="text" name="paddress" id="paddress" size="30"> </td> </tr> <tr> <td>Personal Address</td> <td> <input type="text" name="praddress" id="praddress" size="30"> </td> </tr> <tr> <td>Sex</td> <td> <input type="radio" name="sex" value="male" size="10">Male <input type="radio" name="sex" value="Female" size="10">Female </td> </tr> <tr> <td>City</td> <td> <select name="City"> <option value="-1" selected>select..</option> <option value="New Delhi">NEW DELHI</option> <option value="Mumbai">MUMBAI</option> <option value="Goa">GOA</option> <option value="Patna">PATNA</option> </select></td> </tr> <tr> <td>Course</td> <td><select name="Course">
  • 3. <option value="-1" selected>select..</option> <option value="B.Tech">B.TECH</option> <option value="MCA">MCA</option> <option value="MBA">MBA</option> <option value="BCA">BCA</option> </select></td> </tr> <tr> <td>District</td> <td><select name="District"> <option value="-1" selected>select..</option> <option value="Nalanda">NALANDA</option> <option value="UP">UP</option> <option value="Goa">GOA</option> <option value="Patna">PATNA</option> </select></td> </tr> <tr> <td>State</td> <td><select Name="State"> <option value="-1" selected>select..</option> <option value="New Delhi">NEW DELHI</option> <option value="Mumbai">MUMBAI</option> <option value="Goa">GOA</option> <option value="Bihar">BIHAR</option> </select></td> </tr> <tr> <td>PinCode</td> <td><input type="text" name="pincode" id="pincode" size="30"></td> </tr> <tr> <td>EmailId</td> <td><input type="text" name="emailid" id="emailid" size="30"></td> </tr>
  • 4. <tr> <td>DOB</td> <td><input type="text" name="dob" id="dob" size="30"></td> </tr> <tr> <td>MobileNo</td> <td><input type="text" name="mobileno" id="mobileno" size="30"></td> </tr> <tr> <td> <input type="reset"> </td> <td colspan="2"> <input type="submit" value="Submit Form" /> </td> </tr> </table> </body> </html> output Week 2: To create an html page with differenttypes of frames such as floating frame, navigationframe & mixed frame
  • 5. Program: Mainpage.html <html> <body> <a href="frames.html" target="two">navigation frame</a><br> <a href="floatingframe.html" target="two">floating frame</a><br> <a href="Noframe.html" target="two">no frame</a><br> <a href="mixedframe.html" target="two">mixed frame</a><br> </body> </html> Frame.html <html> <frameset cols="20%,35%,*" scrolling="no" noresize> <frame name="one" src="MainPage.html"></frame> <frame src="aa.gif"></frame> <frame name="two" src="hulk.gif"></frame> </frameset> </html> Floatingframe.html <html> <body> <p> Explanation: There is a problem with the page you are trying to reach and it cannot be displayed. Try the following: * Refresh page: Search for the page again by clicking the Refresh button. The timeout may have occurred due to Internet congestion. * Check spelling: Check that you typed the Web page address correctly. The address may have been mistyped. * Access from a link: If there is a link to the page you are looking for, try accessing
  • 6. the page from that link. If you are still not able to view the requested page, try contacting you <iframe src="bb.gif" height="225" width="500"> </iframe> <iframe src="MainPage.html" height="50%" width="50%"> </iframe> </body> </html> Mixedframe.html <html> <frameset cols="30%,*"> <frame src="pic.html"></frame> <frameset rows="50%,*"> <frame src="video.html" autostart="true"> <frame src="Q3.html" > </frameset> </frameset> </html> navigationframe.html <html> <frameset cols="25%,*" scrolling="no" noresize> <frame name="one" src="MainPage.html"> </frame> <frame name="two" ></frame> <frameset rows="30%,*"> <frame src="hulk.gif"> </frame> </frameset> </html>
  • 7. pic.html <html> <body> <img src="ghanendra.jpg" height="650" width="400"> </body> </html> video.html <html> <body bgcolor="aqua"> <embed src="aa.mp4" width="600" height="300" autostart="true"> </embed> </body> </html> Week 3: Design the webpageby applying the differentstyles using inline, external & internal style sheets. Program: Inline.html: <html> <head> <title>Example of HTML Inline Styles</title> </head> <body> <h1 style="color:red;font-size:30px;">This is a heading</h1> <p style="color:green;font-size:18px;">This is a paragraph.</p> <hr style="border-color:blue;"> </body> </html>
  • 8. Internal.html: <html> <head> <title>Example of HTML Embedded Style Sheet</title> <style type="text/css"> body { background-color: YellowGreen; } h1 { color: red; } p { color: green; } </style> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> </html> External Style Sheet(link & import) link.html: <html> <head> <title>Example of HTML External Style Sheet</title> <link rel="stylesheet" type="text/css" href=" style.css"> </head> <body> <h1>Linking External Style Sheet</h1> <p>The styles of this HTML document are defined in linked style sheet.</p> </body> </html> import.html: <html> <head>
  • 9. <meta charset="UTF-8"> <title>Example of CSS @import rule</title> <style type="text/css"> @import url("/examples/css/style.css"); body { color:blue; font-size:14px; } </style> </head> <body> <div> <h1>Importing External Style Sheet</h1> <p>The layout styles of dese HTML element is dfnd in style.css'.</p> </div> </body> </html> Style.css: body { background-color: powderblue; } h1 { color: blue; } p { color: red; } main.html <html> <body>
  • 10. <h2><a href="inline.html">inline style</a></h2> <h2><a href="internal.html">internal style</a></h2> <h2><a href="link.html">link style</a></h2> <h2><a href="import.html">import style</a></h2> </body> </html> output week 4: Write a java script program to read .XML file and display data in a neat format. The XMLFile You can open libbhanu.xml file to view it. Copy the contents of the file and save it in your computer and name it as library.xml, because we are using the same file name in our example. You can change the name of the file according to your choice later. ExtractData from XML After creating the XML file (also called XML document), we will write JavaScript to read and extract data from the file. The HTML DIV element is a lightweight container, so we decided to use a DIV element to display the XML data on our web page. Tabular format We want to display data in a tabular format with couple of columns. The columns will show the Bookname and Category respectively. To show data in tabular formats (i.e. in two columns), we need to use two more DIV elements inside the main DIV, which serves as a container. We will use CSS to place both the DIV elements side-by-side. libbhanu.xml : <Library> <List>
  • 11. <code>1</code> <BookName>Computer Architecture</BookName> <Category>Computers</Category> <Price>125.60</Price> </List> <List> <code>2</code> <BookName>Advanced Composite Materials</BookName> <Category>Science</Category> <Price>172.56</Price> </List> <List> <code>3</code> <BookName>Asp.Net 4 Blue Book</BookName> <Category>Programming</Category> <Price>56.00</Price> </List> <List> <code>4</code> <BookName>Stategies Unplugged</BookName> <Category>Science</Category> <Price>99.99</Price> </List> <List> <code>5</code> <BookName>Teaching Science</BookName> <Category>Science</Category> <Price>164.10</Price> </List> <List> <code>6</code> <BookName>Challenging Times</BookName>
  • 12. <Category>Business</Category> <Price>150.70</Price> </List> <List> <code>7</code> <BookName>Circuit Bending</BookName> <Category>Science</Category> <Price>112.00</Price> </List> <List> <code>8</code> <BookName>Popular Science</BookName> <Category>Science</Category> <Price>210.40</Price> </List> <List> <code>9</code> <BookName>ADOBE Premiere</BookName> <Category>Computers</Category> <Price>62.20</Price> </List> </Library> extract.html: <html> <head> <title>Extract XML Data using JavaScript</title> <style> #books { font:13px Arial; width:390px; text-align:center;
  • 13. border:solid 1px #000; overflow:hidden; } #books div { width:180px; text-align:left; border:solid 1px #000; margin:1px; padding:2px 5px; } .col1 { float:left; clear:both; } .col2 { float:right; } </style> </head> <body> <div id="books"></div> </body> <script> var oXHR = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); function reportStatus() { if (oXHR.readyState == 4) // REQUEST COMPLETED. showTheList(this.responseXML); // ALL SET. NOW SHOW XML DATA. } oXHR.onreadystatechange = reportStatus; oXHR.open("GET", "libbhanu.xml", true); // true = ASYNCHRONOUS REQUEST (DESIRABLE), false = SYNCHRONOUS REQUEST.
  • 14. oXHR.send(); function showTheList(xml) { var divBooks = document.getElementById('books'); // THE PARENT DIV. var Book_List = xml.getElementsByTagName('List'); // THE XML TAG NAME. for (var i = 0; i < Book_List.length; i++) { // CREATE CHILD DIVS INSIDE THE PARENT DIV. var divLeft = document.createElement('div'); divLeft.className = 'col1'; divLeft.innerHTML = Book_List[i].getElementsByTagName("BookName")[0].childNodes[0].nodeValue; var divRight = document.createElement('div'); divRight.className = 'col2'; divRight.innerHTML = Book_List[i].getElementsByTagName("Category")[0].childNodes[0].nodeValue; // ADD THE CHILD TO THE PARENT DIV. divBooks.appendChild(divLeft); divBooks.appendChild(divRight); } }; </script> </html> output Week 5:
  • 15. To write a Javascriptprogramto define a user defined function for sorting the values in an array. Use HTML5 for user interface. <html> <body> <h1>My First JavaScript</h1> <p>JavaScript can change the content of an HTML element:</p> <button type="button" onclick="myFunction()">Click Me!</button> <p id="demo">This is a demonstration.</p> <script> function myFunction() { var fruits = ['apple', 'orange', 'banana']; var numbers = [10, 20, 2, 3, 0, 500]; for(var i =0;i<numbers.length;i++){ for(var j= i+1;j<numbers.length;j++){ if(numbers[i]>numbers[j]){ var swap = numbers[i]; numbers[i] = numbers[j]; numbers[j] = swap; } } } show_array(fruits); show_array(numbers); } function show_array(array) { var text = ''; for(var i in array) { text += array[i]; text += 'n'; } alert(text); } </script>
  • 16. </body> </html> Dynamic reading of variables from textbox and sorting: <html> <head> <script type="text/javascript"> <!-- function RunTest() { var a= document.forms[0].elements[0].value; try { alert("Value of variable a is : " + a ); } catch ( e ) { alert("Error: " + e.description ); } } //--> </script> </head> <body> <p>Click the following to see the result:</p> <form> <input type="text" name="txtJob" id="txtJob" > <input type="button" value="Click Me" onclick="RunTest();" </form> </body>
  • 18. Week 6: To create an html page to demonstrate exception handling in javascript Create an html page named as ―exception.html‖ and do the following. i. within the script tag write code to handle exception a) define a method RunTest() to get any string values(str) from the user and call the method Areletters(str). b) In Areletters(str) method check whether str contain only alphabets (a-z, A-Z), if not throw exception. c) Define a exception method Input Exception(str) to handle the exception thrown by the above method. ii. Within the body tag define a script tag to call Runtest() method define. <html> <body> Enter the data <input id="demo" type="text"> <button type="button" onclick="RunTest()">Test Input</button> <p id="message"></p> <script type="text/javascript"> function RunTest() { var message, x,y; message = document.getElementById("message"); message.innerHTML = " "; x = document.getElementById("demo"); try {
  • 19. alert(x); var letters = /^[A-Za-z]+$/; y=x.value.match(letters); if(y) document.writeln("this string is accepted"); else throw "not a string"; } catch(err) { message.innerHTML = "Input is " + err; } } </script> </body> </html> Output: After Entering the values in the text box, it it is String ,it is accepted.otherwise it shows as error.
  • 20. Week 7 Write a jsp servlet program to implement the single text field calculator. One.html <html> <body> <form method=”get” action=”./CalculateServlet”> Number 1 : <input type=”text” name=”no1″> <br> Number 2 : <input type=”text” name=”no2″> <br> Operator : <select name=”opt”> <option value=”p”> + </option> <option value=”m”> – </option> <option value=”mul”> * </option> <option value=”d”> / </option>
  • 21. </select> <br> <input type=”submit” value=”Go”> </form> </body> </html> File: CalculateServlet.java import java.io.*; import javax.servlet.*; //import javax.servlet.http.*; public class CalculateServlet extends HttpServlet { public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException { display(); PrintWriter out = response.getWriter(); //out.println(“hello”); String n1 = request.getParameter(“no1”); String n2 = request.getParameter(“no2”); String opt = request.getParameter(“opt”); if(opt.equals(“p”)) out.println(Integer.parseInt(n1) + Integer.parseInt(n2)); else if(opt.equals(“m”)) out.println(Integer.parseInt(n1) – Integer.parseInt(n2)); } public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException { doPost(request,response); } } File : web.xml <web-app> <servlet> <servlet-name>CalculateServlet</servlet-name> <servlet-class>CalculateServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>CalculateServlet</servlet-name> <url-pattern>/CalculateServlet</url-pattern> </servlet-mapping> </web-app>
  • 22. Output After entering the values,based on the selection of operation,the result will be displayed on the browser. Week 8 Write a jsp servlet program to demonstrate session handling using  url rewriting  hidden formfield  cookies  sessions login.html <!DOCTYPE html> <html> <head> <meta charset="US-ASCII">
  • 23. <title>Login Page</title> </head> <body> <form action="LoginServlet" method="post"> Username: <input type="text" name="user"> <br> Password: <input type="password" name="pwd"> <br> <input type="submit" value="Login"> </form> </body> </html> LoginSuccess.jsp <%@ page language="java" contentType="text/html; charset=US-ASCII" pageEncoding="US-ASCII"%> <!DOCTYPE html PUBLIC "- //W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loos e.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US- ASCII"> <title>Login Success Page</title> </head> <body> <% //allow access only if session exists String user = null; if(session.getAttribute("user") == null){ response.sendRedirect("login. html"); }else user = (String) session.getAttribute("user"); String userName = null; String sessionID = null; Cookie[] cookies =
  • 24. request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("u ser")) userName = cookie.getValue(); if(cookie.getName().equals("J SESSIONID")) sessionID = cookie.getValue(); } } %> <h3>Hi <%=userName %>, Login successful. Your Session ID=<%=sessionID %></h3> <br> User=<%=user %> <br> <a href="CheckoutPage.jsp">Checkou t Page</a> <form action="LogoutServlet" method="post"> <input type="submit" value="Logout" > </form> </body> </html> CheckoutPage.jsp <%@ page language="java" contentType="text/html; charset=US-ASCII" pageEncoding="US-ASCII"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Login Success Page</title>
  • 25. </head> <body> <% //allow access only if session exists if(session.getAttribute("user") == null){ response.sendRedirect("login.html"); } String userName = null; String sessionID = null; Cookie[] cookies = request.getCookies(); if(cookies !=null){ for(Cookie cookie : cookies){ if(cookie.getName().equals("user")) userName = cookie.getValue(); } } %> <h3>Hi <%=userName %>, do the checkout.</h3> <br> <form action="LogoutServlet" method="post"> <input type="submit" value="Logout" > </form> </body> </html> output
  • 26. For More Programs visit: https://www.journaldev.com/1907/java-session-management-servlet-httpsession-url-rewriting week 9: To create a php program to demonstrate the different predefined function in array, Math, Data & Regular Expression. Procedure: Create php file named as Regularexpression.php for demonstrating the method for handling various strings with regular expression Array.php for demonstrating the methods for handling the array values Math_function.php to demonstrate the predefined in math objects. Date_time.php to demonstrate the predefined function in date subject.
  • 27. week 10: Write a program in PHP for a simple email processing with attachment using forms One.html <form method="POST" name="email_form_with_php" action="php-form-action.php" enctype="multipart/form-data"> <label for='name'>Name: </label> <input type="text" name="name" > <label for='email'>Email: </label> <input type="text" name="email" > <label for='message'>Message:</label> <textarea name="message"></textarea> <label for='uploaded_file'>Select A File To Upload:</label> <input type="file" name="uploaded_file"> <input type="submit" value="Submit" name='submit'> </form> Send-email-form.php <?php // Pear library includes // You should have the pear lib installed include_once('Mail.php'); include_once('Mail_Mime/mime.php'); //Settings $max_allowed_file_size = 100; // size in KB $allowed_extensions = array("jpg", "jpeg", "gif", "bmp"); $upload_folder = './uploads/'; //<-- this folder must be writeable by the script $your_email = 'tom@amazing-designs.com';//<<-- update this to your email address $errors =''; if(isset($_POST['submit'])) { //Get the uploaded file information $name_of_uploaded_file = basename($_FILES['uploaded_file']['name']); //get the file extension of the file $type_of_uploaded_file = substr($name_of_uploaded_file, strrpos($name_of_uploaded_file, '.') + 1); $size_of_uploaded_file = $_FILES["uploaded_file"]["size"]/1024;
  • 28. ///------------Do Validations------------- if(empty($_POST['name'])||empty($_POST['email'])) { $errors .= "n Name and Email are required fields. "; } if(IsInjected($visitor_email)) { $errors .= "n Bad email value!"; } if($size_of_uploaded_file > $max_allowed_file_size ) { $errors .= "n Size of file should be less than $max_allowed_file_size"; } //------ Validate the file extension ----- $allowed_ext = false; for($i=0; $i<sizeof($allowed_extensions); $i++) { if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0) { $allowed_ext = true; } } if(!$allowed_ext) { $errors .= "n The uploaded file is not supported file type. ". " Only the following file types are supported: ".implode(',',$allowed_extensions); } //send the email if(empty($errors)) { //copy the temp. uploaded file to uploads folder $path_of_uploaded_file = $upload_folder . $name_of_uploaded_file; $tmp_path = $_FILES["uploaded_file"]["tmp_name"]; if(is_uploaded_file($tmp_path)) { if(!copy($tmp_path,$path_of_uploaded_file)) { $errors .= 'n error while copying the uploaded file'; } } //send the email $name = $_POST['name'];
  • 29. $visitor_email = $_POST['email']; $user_message = $_POST['message']; $to = $your_email; $subject="New form submission"; $from = $your_email; $text = "A user $name has sent you this message:n $user_message"; $message = new Mail_mime(); $message->setTXTBody($text); $message->addAttachment($path_of_uploaded_file); $body = $message->get(); $extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply- To"=>$visitor_email); $headers = $message->headers($extraheaders); $mail = Mail::factory("mail"); $mail->send($to, $headers, $body); //redirect to 'thank-you page header('Location: thank-you.html'); } } ///////////////////////////Functions///////////////// // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(n+)', '(r+)', '(t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>File upload form</title>
  • 30. <!-- define some style elements--> <style> label,a, body { font-family : Arial, Helvetica, sans-serif; font-size : 12px; } </style> <!-- a helper script for vaidating the form--> <script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script> </head> <body> <?php if(!empty($errors)) { echo nl2br($errors); } ?> <form method="POST" name="email_form_with_php" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" enctype="multipart/form- data"> <p> <label for='name'>Name: </label><br> <input type="text" name="name" > </p> <p> <label for='email'>Email: </label><br> <input type="text" name="email" > </p> <p> <label for='message'>Message:</label> <br> <textarea name="message"></textarea> </p> <p> <label for='uploaded_file'>Select A File To Upload:</label> <br> <input type="file" name="uploaded_file"> </p> <input type="submit" value="Submit" name='submit'> </form> <script language="JavaScript"> // Code for validating the form // Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml // for details var frmvalidator = new Validator("email_form_with_php"); frmvalidator.addValidation("name","req","Please provide your name"); frmvalidator.addValidation("email","req","Please provide your email"); frmvalidator.addValidation("email","email","Please enter a valid email address");
  • 31. </script> <noscript> <small><a href='http://www.html-form-guide.com/email-form/php-email-form-attachment.html' >How to attach file to email in PHP</a> article page.</small> </noscript> </body> </html> output
  • 32. Week 11 Write a program for PHP for a login script ; create a login database and store username and password One.html form action="" method="post" id="frmLogin"> <div class="error-message"><?php if(isset($message)) { echo $message; } ?></div> <div class="field-group"> <div><label for="login">Username</label></div> <div><input name="user_name" type="text" class="input-field"></div> </div> <div class="field-group"> <div><label for="password">Password</label></div> <div><input name="password" type="password" class="input-field"> </div> </div> <div class="field-group"> <div><input type="submit" name="login" value="Login" class="form- submit-button"></span></div> </div> </form> Login.php <?php session_start(); $conn = mysqli_connect("localhost","root","","phppot_examples"); $message=""; if(!empty($_POST["login"])) { $result = mysqli_query($conn,"SELECT * FROM users WHERE user_name='" . $_POST["user_name"] . "' and password = '". $_POST["password"]."'"); $row = mysqli_fetch_array($result); if(is_array($row)) { $_SESSION["user_id"] = $row['user_id']; } else { $message = "Invalid Username or Password!"; } } ?> Login1.php <?php } else { $result = mysqlI_query($conn,"SELECT * FROM users WHERE user_id='" . $_SESSION["phppot_demopage_459_user_id"] . "'"); $row = mysqli_fetch_array($result); ?> <form action="" method="post" id="frmLogout">
  • 33. <div class="member-dashboard">Welcome <?php echo ucwords($row['display_name']); ?>, You have successfully logged in!<br> Click to <input type="submit" name="logout" value="Logout" class="logout- button">.</div> </form> </div> </div> <?php } ?> Logout.php <?php if(!empty($_POST["logout"])) { $_SESSION["user_id"] = ""; session_destroy(); } ?> output
  • 34. Week 12 Write a program in PHP to add, update and delete using student database Insert data <?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDB"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "INSERT INTO MyGuests (firstname, lastname, email) VALUES ('John', 'Doe', 'john@example.com')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close(); ?> Delete data <?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDB"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error);
  • 35. } // sql to delete a record $sql = "DELETE FROM MyGuests WHERE id=3"; if ($conn->query($sql) === TRUE) { echo "Record deleted successfully"; } else { echo "Error deleting record: " . $conn->error; } $conn->close(); ?> Update data ?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDB"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2"; if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . $conn->error; } $conn->close(); ?> Output: New record created successfully Record deleted successfully Record updated successfully
  • 36. Week 13 Create a DTD to describe a library. Library has one or more books, members and staffs. Each book has BookID(Attribute), Title, one or more Authors, Publisher Year of Publication, ISBN and Price. Each Member has MemeberID(Attribute), Name, Address, Phone number. Each Staff has StaffID(Attribute), Name, Address, Phone number. Each Author has AuthorID(Attribute), Name, Address, Phone number. Each Publisher has PublisherID(Attribute), Name, Address, Phone number. Use it in a XML document. libbhanu.xml : <Library> <List> <code>1</code> <BookName>Computer Architecture</BookName> <Category>Computers</Category> <Price>125.60</Price> </List> <List> <code>2</code> <BookName>Advanced Composite Materials</BookName> <Category>Science</Category> <Price>172.56</Price> </List> <List> <code>3</code> <BookName>Asp.Net 4 Blue Book</BookName> <Category>Programming</Category> <Price>56.00</Price> </List> <List> <code>4</code> <BookName>Stategies Unplugged</BookName> <Category>Science</Category>
  • 37. <Price>99.99</Price> </List> <List> <code>5</code> <BookName>Teaching Science</BookName> <Category>Science</Category> <Price>164.10</Price> </List> <List> <code>6</code> <BookName>Challenging Times</BookName> <Category>Business</Category> <Price>150.70</Price> </List> <List> <code>7</code> <BookName>Circuit Bending</BookName> <Category>Science</Category> <Price>112.00</Price> </List> <List> <code>8</code> <BookName>Popular Science</BookName> <Category>Science</Category> <Price>210.40</Price> </List> <List> <code>9</code> <BookName>ADOBE Premiere</BookName> <Category>Computers</Category> <Price>62.20</Price> </List>
  • 38. </Library> extract.html: <html> <head> <title>Extract XML Data using JavaScript</title> <style> #books { font:13px Arial; width:390px; text-align:center; border:solid 1px #000; overflow:hidden; } #books div { width:180px; text-align:left; border:solid 1px #000; margin:1px; padding:2px 5px; } .col1 { float:left; clear:both; } .col2 { float:right; } </style> </head> <body> <div id="books"></div>
  • 39. </body> <script> var oXHR = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); function reportStatus() { if (oXHR.readyState == 4) // REQUEST COMPLETED. showTheList(this.responseXML); // ALL SET. NOW SHOW XML DATA. } oXHR.onreadystatechange = reportStatus; oXHR.open("GET", "libbhanu.xml", true); // true = ASYNCHRONOUS REQUEST (DESIRABLE), false = SYNCHRONOUS REQUEST. oXHR.send(); function showTheList(xml) { var divBooks = document.getElementById('books'); // THE PARENT DIV. var Book_List = xml.getElementsByTagName('List'); // THE XML TAG NAME. for (var i = 0; i < Book_List.length; i++) { // CREATE CHILD DIVS INSIDE THE PARENT DIV. var divLeft = document.createElement('div'); divLeft.className = 'col1'; divLeft.innerHTML = Book_List[i].getElementsByTagName("BookName")[0].childNodes[0].nodeValue; var divRight = document.createElement('div'); divRight.className = 'col2'; divRight.innerHTML = Book_List[i].getElementsByTagName("Category")[0].childNodes[0].nodeValue; // ADD THE CHILD TO THE PARENT DIV. divBooks.appendChild(divLeft); divBooks.appendChild(divRight); }
  • 41. Create a DTD to describe a Computer.A computer has following details,  Type of computer (this is an attribute), Which can be Desktop PC, Laptop,Palm Top, Server, Minicomputer or mainframe)  A Monitor with Serial Number (Attribute), Make, Model, Year of manufacture,Size, Type (which is either colour or monochrome)  A keyboard with Serial Number (Attribute), Make, Model, Year of manufacture,No of keys, Type( which is either Standard or Enhanced or Multimedia)  A mouse with Serial Number (Attribute), Make, Model, Year of manufacture,No of buttons, Scroll wheel (which is yes or no), Type (Which is Ball or Optical  A Mother board with Serial Number (Attribute),Make,Model,Year ofmanufacture, No of USB ports, No of IDE slots, No of SATA hubs, No of PCIslots, Display Type(Which is VGA or HDMI), Number of Processor slots, Typeof Processors supported (must be a list), Type of RAM supported (Which iseither SD or DDR1 or DDR2 or RD), Maximum Capacity of RAM, Form Factor(which is either AT or Baby AT), On Board sound card (Which is yes or no)  A Microprocessor with Serial Number (Attribute), Make, Model, Year ofmanufacture, speed (in GHz), No of Cores (Single, Dual, Quad)  A power supply with Serial Number (Attribute), Make, Model, Year ofmanufacture, Type (AT, ATX), Wattage One or more hard disks, each Hard disk must have Serial Number (Attribute),  Make, Model, Year of manufacture, capacity and type (Which is IDE or SATAIor SATAII, SCSI) One or more RAM SIMM, with Serial Number (Attribute), Make, Model, Year of manufacture, Type (which must be SD, DDRI, DDRII, RD), capacity, operating frequency. Use it in a XML document. Week 15:
  • 42. Create a Schema to describe a Computer. Use the previous question‘s details and show an instance XML document Week 16:
  • 43. Create a Schema to describe a library. Library has one or more - books, members and staffs.  Each book has BookID(Attribute), Title, one or more Authors, Publisher Year of Publication, ISBN and Price.  Each Member has MemeberID(Attribute), Name, Address, Phone number.  Each Staff has StaffID(Attribute), Name, Address, Phone number.  Each Author has AuthorID(Attribute), Name, Address, Phone number.  Each Publisher has PublisherID(Attribute), Name, Address, Phone number.  Use the above DTD in a sample XML document. book.dtd <!ELEMENT bookdetails (books+)> <!ELEMENT books (title,author,edition,price)> <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT edition (#PCDATA)> <!ELEMENT price (#PCDATA)> book.xml <?xml version="1.0"?> <!DOCTYPE bookdetails SYSTEM "book.dtd"> <?xml:stylesheet type="text/xsl" href="book.xsl"?> <bookdetails> <books> <title> C </title> <author> Balaguruswamy </author> <edition> Edition-II </edition> <price>$30.00</price> </books> <books> <title> C++ </title> <author> yaswanth kanethkar </author> <edition> Edition-I </edition> <price>$35.00</price> </books> <books> <title> JAVA </title> <author> Herbert Schildt </author> <edition> Edition-IV </edition>
  • 44. <price>$50.00</price> </books> </bookdetails> book.xsl <?xml version="1.0"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <center>Book Details</center> </head> <body> <hr width="50%"/> <table border="1" align="center"> <tr> <th> TITLE </th> <th> AUTHOR </th> <th> EDITON </th> <th> PRICE </th> </tr> <xsl:for-each select="bookdetails/books"> <tr> <td> <xsl:value-of select="title"/></td> <td> <xsl:value-of select="author"/></td> <td> <xsl:value-of select="edition"/></td> <td> <xsl:value-of select="price"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> Result:-
  • 45. Week 17: Create a DTD to describe a bank that has one or more customers, accounts or Employee.  Each Customerhas a CustomerID, Name and address.  Each account has an account ID, BranchID, CustomerID,AccountTypeand Balance.  Each Employee has aEmpID, Name,Designation,DOJ, Salary and Address. Use this DTD in a XML file.
  • 46. Week 18: Create Schema describe a bank that has one or more customers, accounts or depositors.Use the previousquestionsdetails.Alsoshow a sample instance XML document