Documente Academic
Documente Profesional
Documente Cultură
ALGORITHM :
Using Dom:
Step1: Get a document builder using document builder factory and parse the xml file to create a DOM object.
Step 2: Get a list of employee elements from the DOM .
Step3: For each employee element get the id, name, age and type.
Create an employee value object and add it to the list.
Step4: At the end iterate through the list and print the employees to verify we parsed it right.
Using Sax
Step1: Create a Sax parser and parse the xml
Step2: In the event handler create the employee object
Step3 : Print out the data
CODING:
Employees.Xml
<?xml version="1.0" encoding="UTF-8"?>
<Personnel>
<Employee type="permanent">
<Name>Seagull</Name>
<Id>3674</Id>
<Age>34</Age>
</Employee>
<Employee type="contract">
<Name>Robin</Name>
<Id>3675</Id>
<Age>25</Age>
</Employee>
<Employee type="permanent">
<Name>Crow</Name>
<Id>3676</Id>
<Age>28</Age>
</Employee>
</Personnel>
DomParser Example.java
a)
}
b)
Get the rootElement from the DOM object.From the root element get all employee elements. Iterate through
each employee element to load the data.
private void parseDocument(){
//get the root element
Element docEle = dom.getDocumentElement();
//get a nodelist of elements
NodeList nl = docEle.getElementsByTagName("Employee");
if(nl != null && nl.getLength() > 0) {
for(int i = 0 ; i < nl.getLength();i++) {
//get the employee element
Element el = (Element)nl.item(i);
//get the Employee object
Employee e = getEmployee(el);
//add it to list
myEmpls.add(e);
}
}
}
c)
/**
* I take an employee element and read the values in, create
* an Employee object and return it
*/
private Employee getEmployee(Element empEl) {
//for each <employee> element get text or int values of
//name ,id, age and name
return Integer.parseInt(getTextValue(ele,tagName));
}
d)
b)
In the event handlers create the Employee object and call the corresponding setter methods.
//Event Handlers
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
{
//reset tempVal = "";
if(qName.equalsIgnoreCase("Employee")) {
//create a new instance of employee
tempEmp = new Employee();
tempEmp.setType(attributes.getValue("type"));
}
}
public void characters(char[] ch, int start, int length) throws SAXException
{
tempVal = new String(ch,start,length); }
public void endElement(String uri, String localName, String qName) throws SAXException
{
if(qName.equalsIgnoreCase("Employee")) {
//add it to the list myEmpls.add(tempEmp); }
else if (qName.equalsIgnoreCase("Name"))
{ tempEmp.setName(tempVal); }
else if (qName.equalsIgnoreCase("Id")) {
tempEmp.setId(Integer.parseInt(tempVal));
}
}
OUTPUT:
Employee Details - Name:Seagull, Type:permanent, Id:3674, Age:34.
Employee Details - Name:Robin, Type:contract, Id:3675, Age:25.
Employee Details - Name:Crow, Type:permanent, Id:3676, Age:28.
RESULT:
Thus the Parsing an XML document using DOM and SAX Parsers is been done and executed successfully.
EX.NO.6
SERVER SIDE APPLICATION USING JSP
STUDENT INFORMATION SYTEM USING JSP AND SERVLET
AIM:
To develop the student webpage information using java servlet and JDBC.
ALGORITHM:
Step 1: Start the program
Step 2:Create main HTML page for student database maintenance
Step 3: Select option to do the following operation Insertion, search ,delete and modify or update the student recode
Main.Html
<html>
<body bgcolor=yellow text=red>
<div align=center>
<label><h2>Student database maintenance</h2> </label>
<TABLE>
<TR><TD><a href="http://localhost:7001/student/register.html">REGISTER</a></TD></T R>
<TR><TD><a href="http://localhost:7001/student/find3">SEARCH</a></TD></TR>
<TR><TD><a href="http://localhost:7001/student/viewall">VIEW ALL </a></TD></TR>
<TR><TD><a href="http://localhost:7001/student/delete2.html">DELETE</a></TD></TR>
<!--<TR><TD><a href="http://localhost:7001/student/update">UPDATE</a></TD></TR>-->
</table>
</div>
</body>
Register.HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
{
loginform(res,false);
}//goGet()
private void loginform(HttpServletResponse res,boolean error)throws
ServletException,IOException {
res.setContentType("text/html");
PrintWriter pr=res.getWriter();
pr.println("<html><body bgcolor=blue text=red>");
pr.println("<div align=center>");
if(error)
{
pr.println("<H2>LOGIN FAILED, PLEASE TRY AGAIN!!!</H2>");
}
pr.println("<form method=post NAME=FORM>");
pr.println("<table><TR><TD><label> please enter your name and password</label></TR></TD>");
pr.println("<TR><TD>Username:<input type=text name=username> ");
pr.println("<TR><TD>Password:<input type=password name=password><br></TR></TD><hr
width=100%></TR></TD>");
pr.println("<TR><TD>Press:<input type=submit name=submit value=Continue></TR></TD>");
pr.println("<TR><TD>clear:<input type=reset name =reset value=Clear></TR></TD></TABLE>");
pr.println("</form></div></body></html>"); }
//loginform()
public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException {
String name=req.getParameter("username");
String pass=req.getParameter("password");
if(logindb(name,pass)) {
RequestDispatcher rd=req.getRequestDispatcher("/main.html");
rd.forward(req,res);
} else {
loginform(res,true); } }
//doPost()
boolean logindb(String name, String pass) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:logindb");
Statement s=con.createStatement();
String sql="select * from stu where username= '" + name + "' AND password= '" + pass + "' ";
ResultSet rs=s.executeQuery(sql);
if(rs.next()) { return true; }
con.close(); }
catch(SQLException s) {
s.printStackTrace();
} catch(Exception e) {
e.printStackTrace(); }
return false;
}
//login()
};
Register1.java
/* INSERTING THE DATA */
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.lang.*;
String branch=req.getParameter("branch");
int m1=Integer.parseInt(req.getParameter("m1"));
int m2=Integer.parseInt(req.getParameter("m2"));
int m3=Integer.parseInt(req.getParameter("m3"));
String grade=req.getParameter("grade");
pr.println("<html><body bgcolor=yellow text=red><div align=center>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:ss");
// pr.println("Get connection");
PreparedStatement pst=con.prepareStatement("Insert into studata values(?,?,?,?,?,?,?,?) ");
pst.setInt(1,id);
pst.setString(2,name);
pst.setInt(3,age);
pst.setString(4,branch);
pst.setInt(5,m1);
pst.setInt(6,m2);
pst.setInt(7,m3);
pst.setString(8,grade);
pst.executeQuery();
con.commit();
pr.println("student information are successfully registered");
pr.println("<a href=http://localhost:7001/student/main.html>goto main page</a>");
pr.println("</html></body>");
con.close(); }
catch(SQLException e)
{
System.out.println(e.getMessage()); }
catch(Exception e) {
e.printStackTrace();
}
}
};
Find3.Java
/* SEARCH THE PARTICULAR RECORD */
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.lang.*;
public class find3 extends HttpServlet {
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException {
res.setContentType("Text/html");
PrintWriter pr=res.getWriter();
pr.println("<html><body bgcolor=black text=green><div align=center>");
pr.println("<form action=http://localhost:7001/student/find3 method=post name=form1>");
pr.println("<h4>Enter the student ID:</h4><input type=text name=id >");
pr.println("<h4>click:</h4><input type=submit name=submit value=search>");
pr.println("</form></div></body></html>"); }
public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException {
try {
res.setContentType("Text/html");
PrintWriter pr=res.getWriter();
String id =req.getParameter("id");
int idno=Integer.parseInt(id);
pr.println("<html><body bgcolor=black text=green><div align=center>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:ss");
//PreparedStatement pst=con.prepareStatement("select * from studata where ID= '" + idno + "' ");
PreparedStatement pst=con.prepareStatement("select * from studata where ID= ? ");
pst.setInt(1,idno);
ResultSet r=pst.executeQuery();
while(r.next()) {
pr.println(r.getInt(1)+"\t"+r.getString(2)+"\t"+r.getInt(3)+"\t"+r.getSt
ring(4)+"\t"+r.getInt(5)+"\t"+r.getInt(6)+"\t"+r.getInt(7)+"\t"+r.getString(8) );
pr.println("<br>");
}
pr.println("<a href=http://localhost:7001/student/main.html>goto main page</a>"); pr.println("</html></body>");
} catch(SQLException e) {
System.out.println(e.getMessage()); }
catch(Exception e) {
e.printStackTrace();
} } };
Delete2.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.lang.*;
public class delete2 extends HttpServlet {
public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException {
try {
res.setContentType("Text/html");
PrintWriter pr=res.getWriter();
pr.println("<html><body bgcolor=black text=yellow>");
String idno=req.getParameter("idno");
int id=Integer.parseInt(idno);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:ss");
pr.println("get connected");
//PreparedStatement pst=con.prepareStatement("Delete from studata where ID= '" + id + "' ");
PreparedStatement pst=con.prepareStatement("Delete from studata where ID= ? ");
pst.setInt(1,id);
pst.executeUpdate();
pr.println("<h2>student record is successfully deleted");
pr.println("<a href=http://localhost:7001/student/main.html>goto main page</a>"); pr.println("</html></body>");
con.commit(); }
catch(SQLException e) {
System.out.println(e.getMessage()); }
catch(Exception e) {
e.printStackTrace();
}
}
};
OUTPUT:
Student table:
RESULT :
Thus student information java script program is successfully completed
EX NO:07.
WEB CUSTOMISATION
CREATION OF WEB APPLICATION USING PHP
AIM:
To create a calculator web appliction using php.
ALGORITHM :
Step1 : Start the program
Step2 : Create a php web page calc.php
Step3: Using form and input type tag create various buttons, textbox, radio button etc.
Step4: calcute the output for various option
Step5: Using post method display the result in next page.
Step6: Stop the program.
Coding: Calc.php:
<?php
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Calculator</title>
</head>
<body>
<?php
// basic calculator program
function showForm() {
?>
All field are required, however, if you forget any, we will put a random number in for you. <br />
<table border="0">
if (empty($_POST['number2'])) {
(int)$_POST['number2'] = rand(1,200);
}
if (empty($_POST['rounding'])) {
$round = 0;
}
if (!isset($_POST['opt'])) {
$errors[] = "You must select an operation.";
$error = true;
}
if (strpbrk($_POST['number'],"-") and strpbrk($_POST['number2'],"0.") and $_POST['opt'] == "^") {
$errors[] = "You cannot raise a negative number to a decimal, this is impossible.
<a href=\"http://hudzilla.org/phpwiki/index.php?title=Other_mathematical_conv ersion_functions\">Why?</a>";
$error = true;
}
if ($error != false) {
echo "We found these errors:";
echo "<ul>";
foreach ($errors as $e) {
echo "<li>$e</li>";
}
echo "</ul>";
} else {
switch ($_POST['opt']) { case "+": $result = (int)strip_tags($_POST['number']) +
(int)strip_tags($_POST['number2']);
echo "The answer to " . (int)strip_tags($_POST['number']) . " $_POST[opt] " . (int)strip_tags($_POST['number2']) .
" is $result.";
break;
case "-";
$b = floor($result);
echo "$result rounded down is $b";
echo "<br />";
$h = round($result,(int)$_POST['rounding']); echo "$result rounded to $_POST[rounding] digits is " . $h;
break;
case "^2":
$result = (int)strip_tags($_POST['number']) * (int)strip_tags($_POST['number2']); $a = (int)$_POST['number2'] *
(int)$_POST['number2'];
echo "The answer to " . (int)$_POST['number'] . "<sup>2</sup> is " . $result;
echo "<br />";
echo "The answer to " . (int)$_POST['number2'] . "<sup>2</sup> is " . $a;
break;
case "sqrt":
$result = (int)strip_tags(sqrt($_POST['number']));
$sqrt2 = (int)strip_tags(sqrt($_POST['number2']));
echo "The square root of " . (int)strip_tags($_POST['number']) . " is " . $result; echo "<br />";
echo "The square root of " . (int)strip_tags($_POST['number2']) . " is " . $sqrt2; echo "<br />";
echo "The square root of " . (int)strip_tags($_POST['number']) . " rounded to " . strip_tags($_POST[rounding]) . "
digits is " . round($result,(int)$_POST['rounding']);
echo "<br />";
echo "The square root of " . (int)strip_tags($_POST['number2']) . " rounded to " . strip_tags($_POST[rounding]) . "
digits is " . round($sqrt2,(int)strip_tags($_POST['rounding']));
break;
case "^":
$result = (int)strip_tags(pow($_POST['number'],$_POST['number2']));
$pow2 = (int)strip_tags(pow($_POST['number2'],$_POST['number']));
echo (int)$_POST['number'] . "<sup>" . strip_tags($_POST[number2]) . "</sup> is " . $result;
echo "<br />"; echo (int)$_POST['number2'] . "<sup>" . strip_tags($_POST[number]) . "</sup> is " . $pow2;
break;
}
}
}
echo "<br />";
?>
<a href="calc.php">Go Back</a>
</body>
</html>
OUTPUT:
RESULT:
Thus the calculator web appliction using php is been developed succesfully.
EX NO. 8
DEVELOPMENT OF E-BUSINESS APPLICATION.
AIM:
To create a calculator web appliction using php.
ALGORITHM :
Step1: Start the program
Step2: Create a php web page contact.php
Step3: Using form and input type tag create various buttons, textbox, radio button etc.
Step4: Get the necessary field from the user.
Step5: Using post method display the result in next page.
Step6: Stop the program.
CODING:
Contact.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Web and Crafts</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body> <!-- #header-wrapper -->
<?php $name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$phonenumber = $_POST['phonenumber'];
$email = $_POST['email'];
$message = $_POST['message'];
$error=0;
if (isset($_POST['submit'])) {
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$email == "" && (!strstr($email,"@") || !strstr($email,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
$error=1;
}
if(empty($name) || empty($phonenumber) || empty($email ) || empty($message))
{
echo "<h2>Use Back - fill in all required fields </h2>\n";
$error=1;
}
if($error!=1) {
$todayis = date("l, F j, Y, g:i a") ;
$attn = $subject ;
$subject = "mail from $email";
$message = stripcslashes($message);
$mailmessage = " $todayis [EST] \n Subject: $subject \n Message: $message \n From: $name ($email)\n City:
$city\n Pin/Zip code: $zip\n PhoneNo: $phonenumber\n ";
$from ="From: $email \r\n";
mail("99abin@gmail.com" ,$subject, $mailmessage,$from);
</td>
</tr>
<tr>
<td align="right" valign="center">
<strong> City : </strong> </td>
<td align="left" valign="center">
<input style="WIDTH: 205px; HEIGHT: 22px" size="26" name="city" />
</td> </tr>
<tr>
< td align="right" valign="center">
<strong> <font color="#ff0000">*</font> Phone No : </strong> </td>
<td align="left" valign="center"> <input style="WIDTH: 168px; HEIGHT: 22px" size="21"
name="phonenumber" />
</td> </tr>
<tr>
<td align="right" valign="center">
<strong> <font color="#ff0000">*</font> Email : </strong> </td>
<td align="left" valign="center"><input style="WIDTH: 207px; HEIGHT: 22px" size="26" name="email" />
</td>
</tr>
<tr>
<td align="right" valign="center">
<strong> <font color="#ff0000">*</font> Your Message :</strong>
</td>
<td align="left" valign="center">
<textarea style="WIDTH: 346px; HEIGHT: 158px" name="message" rows="8" cols="37"> </textarea></td> </tr>
<tr>
<td valign="center" align="right">
</td>
</td>
</td>
OUTPUT:
RESULT:
Thus the Php application has been developed and executed successfully.
AboutUs.php
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>EBookBiz Demo</title>
<link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="wrapper">
<!-- header starts-->
<?php include_once 'Header.php'; ?>
<!-- header ends -->
<div id="content">
<p>
<br />
<br />
<br />
<span class="font14b">
We are an online store selling IT and Computer related books. We serve student community and offer special
discounts to students. <br />
<br />
Contact Us for more details</span></p>
<p><span class="font14b">EBookBiz<br />
Tirupur<br />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>EBookBiz Demo</title>
<link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="wrapper">
<!-- header starts-->
<?php include_once 'Header.php';
?>
<!-- header ends -->
<div id="content">
Selected Books
<br />
<br />
<table width="500" border="1" cellpadding="5" cellspacing="0">
<tr>
<td width="43" align="center" valign="top" bgcolor="#FFFFCC">S.No</td>
<td width="342" align="left" valign="top" bgcolor="#FFFFCC">Book Title</td>
<td width="77" align="left" valign="top" bgcolor="#FFFFCC">Price (Rs)</td>
</tr>
<?php
$selectedBooks = $aOrderDetails['fSelectBook'];
$sno = 1;
$total = 0;
$numBooks = count($selectedBooks);
for($i=0; $i<$numBooks; $i++)
{
</div>
</body>
</html>
DEPARTMENT.PHP
<?php
session_start();
include ('Db.php');
if(!isset($_SESSION['ses_username']))
{
header("Location:Login.php");
}
if(isset($_POST['seldept']))
{
header("Location: BookList.php?fDepartment=".$_POST['fDepartment']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>EBookBiz Demo</title>
<link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="wrapper">
<!-- header starts-->
<?php
include_once 'Header.php';
?>
<!-- header ends -->
<div id="content">
<br />
<br />
<br />
<br />
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="deptform">
<table width="332" border="0" align="center" cellpadding="5" cellspacing="1" class="tabBorder">
<tr>
<td colspan="2" align="left" valign="top" bgcolor="#CCCCCC"> </td>
</tr>
<tr>
<td width="144" align="right" valign="top" bgcolor="#EAEAEA">Choose the Department </td>
<td width="168" align="left" valign="top" bgcolor="#EAEAEA"><label>
<select name="fDepartment">
<option>Select Department</option>
<option value="1">Computer Science</option>
<option value="2">IT</option>
</select>
</label>
</td>
</tr>
<tr>
<td colspan="2" align="center" valign="top" bgcolor="#EAEAEA">
<label>
<input type="submit" name="seldept" value="Show Book List" />
</label></td>
</tr>
</table>
</form>
<br />
<br />
<br />
<br />
<br />
<span class="font14b"> </span>
</div>
<div id="footer">
</div>
</div>
</body>
</html>
Booklist.Php
<?php
session_start();
include ('Db.php');
if(!isset($_SESSION['ses_username']))
{
header("Location:Login.php");
}
if(isset($_POST['fPlaceOrder']))
{
$_SESSION['orderdetails'] = $_POST; header("Location: Order.php");
} ?>
<?php
$dept = $_GET['fDepartment'];
$query = "SELECT id, title, authorname, price, department FROM books WHERE department = ".$dept;
$result = mysql_query($query, $con);
$i = 1;
while($row = mysql_fetch_assoc($result))
{
?>
<tr>
<td align="center" valign="top"><?php echo $i; ?></td>
<td align="left" valign="top"><?php echo $row['title']; ?></td>
<td align="left" valign="top"><?php echo $row['authorname']; ?></td>
<td align="left" valign="top">Rs. <?php echo $row['price']; ?></td>
<td align="center" valign="top">
<input type="checkbox" name="fSelectBook[]" value="<?php echo $row['id']; ?>" />
</td>
</tr>
<?php
$i = $i + 1;
}
?>
</table>
<br />
<br />
<div style="text-align:center;">
<input type="submit" name="fPlaceOrder" value="Place Order" />
</div>
</form>
<br />
<br />
<br />
<br />
<br />
<span class="font14b">
</span>
</div> <div id="footer">
</div>
</div>
</body>
</html>
Db.php
<?php
$db_hostname = 'localhost';
$db_dbname = 'ebookbiz';
$db_username = 'root';
$db_password = '';
$con = mysql_pconnect($db_hostname, $db_username, $db_password);
mysql_select_db($db_dbname, $con); ?>
Header.php
<div id="header">
<div id="logo">
<span class="logoStyle">E-BOOK-BIZ</span>
</div>
<div id="navigation">
<a href="index.php" class="navLink">Home</a> |
<a href="Login.php" class="navLink">Login</a> |
include ('Db.php');
if(isset($_POST['Submit']))
{
$login_id = $_POST['fLoginId'];
$password = $_POST['fPassword'];
$query = "SELECT username FROM users WHERE login_id = '".$login_id."' AND password = '".$password."'";
$result = mysql_query($query, $con);
if($result) { while($row = mysql_fetch_assoc($result))
{
$userName = $row['username'];
}
$_SESSION['ses_username'] = $userName;
header("Location: Department.php");
}
else
{
$resultmsg = "Please provide correct login id and password";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>EBookBiz Demo</title>
<link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="wrapper">
<!-- header starts-->
<?php
include_once 'Header.php'; ?>
<!-- header ends -->
<div id="content">
<br />
<br />
<br />
<br />
<div>
<?php
if(isset($resultmsg))
{
echo $resultmsg;
}
?>
</div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform">
<table width="332" border="0" align="center" cellpadding="5" cellspacing="1" class="tabBorder">
<tr>
<td colspan="2" align="left" valign="top" bgcolor="#CCCCCC">Login</td>
</tr>
<tr>
<td width="144" align="right" valign="top" bgcolor="#EAEAEA">Login ID </td>
<td width="168" align="left" valign="top" bgcolor="#EAEAEA">
<label>
</div>
<div id="footer">
</div>
</div>
</body>
</html>
Logout.php
<?php
session_start();
session_destroy();
header("Location:index.php");
?>
Registration.php
<?php
session_start();
include ('Db.php');
if(!empty($_REQUEST['Submit']))
{
//echo 'form submitted for registration...';
$name = $_POST['fName'];
$address1 = $_POST['fAddress1'];
$address2 = $_POST['fAddress2'];
$city = $_POST['fCity'];
$state = $_POST['fState'];
$pincode = $_POST['fPincode'];
$phone = $_POST['fPhone'];
$email = $_POST['fEmail'];
$login_id = $_POST['fLoginId'];
$password = $_POST['fPassword'];
$query = "INSERT INTO users ( id, username, address1, address2, city, state, pincode, phone, email,login_id,
password ) VALUES ( null, '{$name}', '{$address1}', '{$address2}',
'{$city}','{$state}','{$pincode}','{$phone}','{$email}', '{$login_id}','{$password}' )";
mysql_query($query, $con);
$msg = 'Registration successful.';
header("Location: Login.php?msg=success");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>EBookBiz Demo</title>
<link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
<script>
function validate()
{
alert("ssssssssssssss");
var frm = document.forms['regform'];
if(document.regform.fName.value == '')
{
alert("Please enter your Name)";
return false;
}
if(frm.fEmail.value == '')
{
alert("Please enter your Email");
return false;
}
if(frm.fLoginId.value == '')
{
alert("Please enter your Login Id");
return false;
}
if(frm.fPassword.value == '')
{
alert("Please enter your Password");
return false;
}
}
</script>
</head>
<body>
<div id="wrapper">
<!-- header starts-->
<?php
include_once 'Header.php';
?>
<!-- header ends -->
<div id="content">
<br />
<br />
<br />
<br />
<div>
<?php
if(isset($msg))
{
//echo $msg;
}
?>
</div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="regform" onsubmit="return
validate();">
<table width="332" border="0" align="center" cellpadding="5" cellspacing="1" class="tabBorder">
<tr>
<td colspan="2" align="left" valign="top" bgcolor="#CCCCCC">Registration</td>
</tr>
<tr>
<td width="144" align="right" valign="top" bgcolor="#EAEAEA">Name <em>*</em>
</td>
<td width="168" align="left" valign="top" bgcolor="#EAEAEA">
<input name="fName" type="text" id="fName" />
</td>
</tr>
<tr>
<td width="144" align="right" valign="top" bgcolor="#EAEAEA">Address1</td>
<td width="168" align="left" valign="top" bgcolor="#EAEAEA">
<input name="fAddress1" type="text" id="fAddress1" />
</td>
</tr>
<tr>
<td width="144" align="right" valign="top" bgcolor="#EAEAEA">Address2</td>
<tr>
<td width="144" align="right" valign="top" bgcolor="#EAEAEA">Email ID <em>*</em>
</td>
<td width="168" align="left" valign="top" bgcolor="#EAEAEA">
<input name="fEmail" type="text" id="fEmail" />
</td>
</tr>
<tr>
<td height="15" colspan="2" align="right" valign="top"bgcolor="#EAEAEA"></td>
</tr>
<tr>
<td width="144" align="right" valign="top" bgcolor="#EAEAEA">Login ID <em>*</em>
</td>
<td width="168" align="left" valign="top" bgcolor="#EAEAEA">
<input name="fLoginId" type="text" id="fLoginId" />
</td>
</tr>
<tr>
<td width="144" align="right" valign="top" bgcolor="#EAEAEA">Password <em>*</em>
</td>
<td width="168" align="left" valign="top" bgcolor="#EAEAEA">
<input name="fPassword" type="password" id="fPassword" />
</td>
</tr>
<tr>
<td colspan="2" align="center" valign="top" bgcolor="#EAEAEA">
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</td>
</tr>
</table>
</form>
<br />
<br />
<br />
<br />
<br />
<span class="font14b">
</span>
</div>
<div id="footer">
</div>
</div>
</body>
</html>
Stylesheet
#wrapper
{
margin:auto;
width: 980px;
min-height: 600px;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
color:#333333;
border-left:#333333 1px solid;
text-decoration:none;
}
.navLink:hover {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
font-weight: bold;
color: #009900;
text-decoration:underline;
}
.font14b {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
color: #000000;
}
.tabBorder {
border-bottom:#000000 1px solid;
border-left:#000000 1px solid;
border-top:#000000 1px solid;
border-right:#000000 1px solid;
}
AboutUs.php:
Login.php:
RegistrationFrom.php:
Department.php:
BookList.php:
Order.php: