Академический Документы
Профессиональный Документы
Культура Документы
function setcookie(cname,cvalue)
{
document.cookie = cname + "=" +cvalue;
}
<b>UserName</b> <input type="text" name="username"
onBlur="setcookie(this.name,this.value)">
########
<%
IF BlnIsValidUser = True Then
Response.Cookies("CURRENT_USER")= StrUsername
%>
function IsAlphab(FieldVal)
{
var FieldLength = FieldVal.length;
for (var i=0; i<FieldLength; i++)
{
if (!isNaN(FieldVal.charAt(i)))
{
return (false);
}
}
return (true);
}
function IsInt(FieldVal)
{
var FieldLength = FieldVal.length;
for (var i=0; i<FieldLength; i++)
{
if (isNaN(FieldVal.charAt(i)))
{
return (false);
}
}
return (true);
}
function val1(form2)
{
if(form2.elements[0].value=="")
{
Page 1
ASP CODE
alert(form2.elements[0].name+" must be filled");
document.form2.elements[0].focus();
return(false);
}
if(form2.elements[1].value=="")
{
alert(form2.elements[1].name+" must be filled");
document.form2.elements[1].focus();
return(false);
}
if(form2.elements[2].value=="")
{
alert(form2.elements[2].name+" must be filled");
document.form2.elements[2].focus();
return(false);
}
if(form2.elements[3].value=="")
{
alert(form2.elements[3].name+" must be filled");
document.form2.elements[3].focus();
return(false);
}
if(form2.elements[4].value=="")
{
alert(form2.elements[4].name+" must be filled");
document.form2.elements[4].focus();
return(false);
}
if(form2.elements[5].value=="")
{
alert(form2.elements[5].name+" must be filled");
document.form2.elements[5].focus();
return(false);
}
if(form2.elements[6].value=="")
{
alert(form2.elements[6].name+" must be filled");
document.form2.elements[6].focus();
return(false);
}
if (!IsInt(document.form2.elements[6].value))
{
alert("Telephone number must be integer");
document.form2.elements[6].focus();
return(false);
}
if(form2.elements[7].value=="")
{
alert(form2.elements[7].name+" must be filled");
document.form2.elements[7].focus();
return(false);
}
if(document.form2.elements[7].value != "")
Page 2
ASP CODE
{
pass = document.form2.elements[7].value.indexOf('@',0);
pass1 = document.form2.elements[7].value.indexOf('.',0);
if((pass==-1) || (pass1==-1))
{
alert("Not a valid Email address");
document.form2.elements[7].focus();
return (false);
}
}
if(form2.elements[8].value=="")
{
alert(form2.elements[8].name+" must be filled");
document.form2.elements[8].focus();
return(false);
}
if( (form2.elements[10].value==""))
{
alert(form2.elements[10].name+" must be filled and");
document.form2.elements[10].focus();
return(false);
}
return(true);
<%
Dim dcnDB
Dim rsquery
Dim StrUsername, StrPassword, Strpassword1, StrBuyerQuery, StrNewBuyerQuery,
BlnDuplicateBuyer, ObjRSBuyer
rsquery("Username") = StrUsername
rsquery("Password") = StrPassword
rsquery.update
rsquery.Close
dcnDB.Close
response.redirect("user.html")
Page 3
ASP CODE
%>
rsquery.AddNew
rsquery("Firstname") = Strfirstname
rsquery("Lastname") = Strlastname
rsquery("Add1") = Stradd1
rsquery("City") = Strcity
rsquery("State") = Strstate
rsquery("Country") = StrCountry
rsquery("Telephone") = Strphonenumber
rsquery("Email") = Stremail
rsquery("Sex") = Strsex
rsquery("Branch") = Strbranch
rsquery.update
rsquery.Close
dcnDB.Close
response.redirect("report.asp")
%>
set rs=Server.CreateObject("ADODB.recordset")
Page 4
ASP CODE
if rs.RecordCount<>0 then
Session("pro_id")=rs.Fields("profile_id")
Session("fname")=rs.Fields("fname")
Session("gender")=rs.Fields("gender")
Response.Cookies("pro_id")=Request("id")
Page 5
ASP CODE
'---- ConnectPromptEnum Values ----
Const adPromptAlways = 1
Const adPromptComplete = 2
Const adPromptCompleteRequired = 3
Const adPromptNever = 4
'---- ConnectModeEnum Values ----
Const adModeUnknown = 0
Const adModeRead = 1
Const adModeWrite = 2
Const adModeReadWrite = 3
Const adModeShareDenyRead = 4
Const adModeShareDenyWrite = 8
Const adModeShareExclusive = &Hc
Const adModeShareDenyNone = &H10
'---- IsolationLevelEnum Values ----
Const adXactUnspecified = &Hffffffff
Const adXactChaos = &H00000010
Const adXactReadUncommitted = &H00000100
Const adXactBrowse = &H00000100
Const adXactCursorStability = &H00001000
Const adXactReadCommitted = &H00001000
Const adXactRepeatableRead = &H00010000
Const adXactSerializable = &H00100000
Const adXactIsolated = &H00100000
Page 6
ASP CODE
rsquery.AddNew
rsquery("companyname") = Strcompanyname
rsquery("post") = Strpost
rsquery("salary") = Strsalary
rsquery("branch") = Strbranch
rsquery.update
rsquery.Close
dcnDB.Close
response.redirect("report.asp")
%>
<body background="image321.gif">
</body>
<html>
<%
Option Explicit
Dim dcnDB,rsquery,flag,strselect,strcheck,StrUsername,Strpost,Strsalary,Strbranch,
StrPassword, StrLoginQuery,check, BlnIsValidUser, ObjCon, ObjRSLogin
flag=0
StrUsername = Trim(Request.Form("companyname"))
Strpost = Trim(Request.Form("post"))
Strsalary = Trim(Request.Form("salary"))
Strbranch = Trim(Request.Form("branch"))
%>
################### DELETE DATABASE VALUE ##################
<%
Option Explicit
Dim StrUsername,strLoginQuery,strcheck,strselect, BlnIsValidUser, ObjCon, ObjRSLogin
StrUsername = Trim(Request.Form("companyname"))
Set ObjCon = Server.CreateObject("ADODB.Connection")
ObjCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=
D:\bugs.mdb"
ObjCon.Open
strselect="select count(*) from company WHERE companyname='"&StrUsername&"'"
set strcheck=objcon.Execute(strselect)
IF strcheck(0) > 0 Then
ObjCon.Close
%>
Page 8
ASP CODE
foreach $namevalue(@values)
{
($key, $value)=split(/=/,$namevalue);
$hash{$key}=$value;
}
%hash=decode(%hash);
$dbh =
DBI->connect("DBI:mysql:database=$database;host=$host","$dbuser","$dbpass") || die
"\nDB connection error!\n";
$query = $dbh->prepare("SELECT username,password from admin");
$test=$query->execute();
$flag=1;
while(@row = $query->fetchrow_array())
{
($name,$pass) = @row;
if(($hash{username}=~ /^$name$/) && ($hash{password}=~ /^$pass$/))
{
$flag=0;
last;
}
}
$dummy=0;
if($flag == $dummy)
{
print <<htmllog;
<p>
<p>
<p>
<META HTTP-EQUIV="refresh"; content="2;url=http://localhost/bugs/Adminmenu.html">
<font face ='Comic sans MS' color='#996633' size=5>
<center><h1>Login Successful !</h1>
</center>
Page 10
ASP CODE
htmllog
}
else
{
print <<unsuchtml
<p>
<p>
<p>
<META HTTP-EQUIV="refresh";
content="2;url=http://localhost/bugs/Administrator.html">
<h1><center>Login Fail !</center></h1>
<INPUT TYPE=HIDDEN name="member" value=$hash{membernum}>
</font>
unsuchtml
}
undef($query);
$dbh->disconnect;
}
print "</p></body></html>";
sub decode
{
(%ha)=@_;
foreach $key(keys %ha)
{
$temp=$ha{$key};
$temp=~tr/+/ /;
$temp=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$ha{$key}=$temp;
}
return %ha;
}
#!c:/perl/bin/perl.exe
use DBI;
$host = "localhost"; # your database server, can be localhost
$database = "consultancy"; # connecting database
$table = "Username"; # table within the database
$dbuser = "root"; # database login userid
$dbpass = ""; # database login password
$dbh=DBI->connect("dbi:mysql:dbname=consultancy","$dbuser","$dbpass");
print "Content-Type: text/html\n\n";
print <<abc;
<html>
<body bgcolor=#fdfdfd>
<p>
abc
#print "Form request Method : $ENV{'REQUEST_METHOD'}\n";
$cookie=$ENV{HTTP_COOKIE};
if($ENV{'REQUEST_METHOD'}=~ /^GET$/i)
Page 11
ASP CODE
{
@values=split(/&/, $ENV{'QUERY_STRING'});
foreach $namevalue(@values)
{
($key, $value)=split(/=/,$namevalue);
$namevalue = ~ tr/+/ /;
$hash{$key}=$value;
}
%hash=decode(%hash);
}
elsif($ENV{'REQUEST_METHOD'}=~ /^post$/i)
{
read(stdin,$buffer,$ENV{'CONTENT_LENGTH'});
@values=split(/&/, $buffer);
foreach $namevalue(@values)
{
($key, $value)=split(/=/,$namevalue);
$namevalue= ~ tr/+/ /;
$hash{$key}=$value;
# print"$key = $hash{$key}";
}
%hash=decode(%hash);
if(($hash{FirstName}=~ /^$/))
{
print <<htmllog;
<html>
<BODY bgColor=#ccccff>
<p>
<p>
<p>
<META HTTP-EQUIV="refresh"; content="2;url=http://localhost/bugs/User.html">
<center><h1>First Name must be filled !</h1>
</center>
</p></body></html>
htmllog
die;
}
if(($hash{LastName}=~ /^$/))
{
print <<htmllog;
<html>
<BODY bgColor=#ccccff>
<p>
<p>
<p>
<META HTTP-EQUIV="refresh"; content="2;url=http://localhost/bugs/User.html">
<center><h1>LastName must be filled!</h1>
</center>
</p></body></html>
htmllog
Page 12
ASP CODE
die;
}
if(($hash{Add1}=~ /^$/))
{
print <<htmllog;
<html>
<BODY bgColor=#ccccff>
<p>
<p>
<p>
<META HTTP-EQUIV="refresh"; content="2;url=http://localhost/bugs/User.html">
<center><h1>Address must be filled!</h1>
</center>
</p></body></html>
htmllog
die;
}
if(($hash{City}=~ /^$/))
{
print <<htmllog;
<html>
<BODY bgColor=#ccccff>
<p>
<p>
<p>
<META HTTP-EQUIV="refresh"; content="2;url=http://localhost/bugs/User.html">
<center><h1>City must be filled !</h1>
</center>
</p></body></html>
htmllog
die;
}
if(($hash{State}=~ /^$/))
{
print <<htmllog;
<html>
<BODY bgColor=#ccccff>
<p>
<p>
<p>
<META HTTP-EQUIV="refresh"; content="2;url=http://localhost/bugs/User.html">
<center><h1>State must be filled !</h1>
</center>
</p></body></html>
htmllog
die;
}
if(($hash{Country}=~ /^$/))
{
print <<htmllog;
<html>
<BODY bgColor=#ccccff>
<p>
<p>
<p>
<META HTTP-EQUIV="refresh"; content="2;url=http://localhost/bugs/User.html">
<center><h1>Telephone must be filled !</h1>
Page 13
ASP CODE
</center>
</p></body></html>
htmllog
die;
}
#htmllog
# die;
# }
if(($hash{Email}=~ /^$/))
{
print <<htmllog;
<html>
<BODY bgColor=#ccccff>
<p>
<p>
<p>
<META HTTP-EQUIV="refresh"; content="2;url=http://localhost/bugs/User.html">
<center><h1>Email must be filled !</h1>
</center>
</p></body></html>
htmllog
die;
}
if( ($hash{Branch}=~ /--/) )
{
print <<htmllog;
<html>
<BODY bgColor=#ccccff>
<p>
<p>
<p>
<META HTTP-EQUIV="refresh"; content="2;url=http://localhost/bugs/User.html">
<center><h1>Branch must be filled !</h1>
</center>
</p></body></html>
htmllog
die;
}
Page 15
ASP CODE
<th align="center">
Branch
</th>
</tr>
<form name="frmdelete" method="post" action="">
STARTHTML
print"</td>";
print"<td align=\"center\">";
print"$Branch";
print"</td>";
print"</tr>";
}
undef($query);
$dbh->disconnect;
print <<ENDHTML
</td>
</tr>
</table>
</form>
<table align="center" width=60% border=0>
<tr>
<td>
</td>
</tr>
<tr>
<td align="center">
<input type="button" value=" close "
onclick="javascript:history.back();">
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</table>
</td>
Page 16
ASP CODE
</tr>
</table>
</body>
</html>
ENDHTML
}
print "</p></body></html>";
sub decode
{
(%ha)=@_;
foreach $key(keys %ha)
{
$temp=$ha{$key};
$temp=~tr/+/ /;
$temp=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$ha{$key}=$temp;
}
return %ha;
}
#!c:/perl/bin/perl.exe
print "Content-Type:text/html\n\n";
use DBI;
$host = "localhost"; # your database server, can be localhost
$database = "consultancy"; # connecting database
$table = "Company"; # table within the database
$dbuser = "root"; # database login userid
$dbpass = ""; # database login password
$dbh=DBI->connect("dbi:mysql:dbname=consultancy","$dbuser","$dbpass");
print <<abc;
<html>
<body bgcolor=#fdfdfd>
<p>
abc
#print "Form request Method : $ENV{'REQUEST_METHOD'}\n";
if($ENV{'REQUEST_METHOD'}=~/GET/i)
{
# print "<p> $ENV{'QUERY_STRING'}</p>";
@values=split(/&/, $ENV{'QUERY_STRING'});
# print "<p>@values</p>";
foreach $namevalue(@values)
{
($key, $value)=split(/=/,$namevalue);
$namevalue = ~ tr/+/ /;
$hash{$key}=$value;
}
%hash=decode(%hash);
}
elsif($ENV{'REQUEST_METHOD'}=~ /^post$/i)
{
Page 17
ASP CODE
read(stdin,$buffer,$ENV{'CONTENT_LENGTH'});
@values=split(/&/, $buffer);
foreach $namevalue(@values)
{
($key, $value)=split(/=/,$namevalue);
$namevalue= ~ tr/+/ /;
$hash{$key}=$value;
}
%hash=decode(%hash);
}
print "</p></body></html>";
sub decode
{
(%ha)=@_;
foreach $key(keys %ha)
{
$temp=$ha{$key};
$temp=~tr/+/ /;
$temp=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$ha{$key}=$temp;
}
return %ha;
}
try
{
out.write("<html>\n");
out.write(" <head>\n");
out.write("<LINK href=\"1 (9).css\" type=text/css rel=\"stylesheet\">");
out.write(" <meta http-equiv=\"Content-Type\" content=\"text/html;
charset=UTF-8\">\n");
out.write(" <title>Universal Book Shop</title>\n");
out.write(" </head>\n");
out.write(" \n");
out.write(" \n");
out.write(" <BODY bgcolor=\"#fdfdfd\"> <FORM
ENCTYPE=\"multipart/form-data\" ACTION=\"http://localhost:8080/servlet/upload2\"
METHOD=POST>\n");
out.write("\t\t<br><br><br>\n");
out.write("\t <center><table border=\"2\" >\n");
out.write(" <tr><center><td colspan=\"2\"><p
align=\"center\"><B><font color=\"#black\"> UPLOADING THE
FILE</B><center></td></tr>\n");
out.write(" <tr><td><b><font color=\"#black\">Choose the
file To Upload:</b></td>\n");
out.write(" <td><INPUT NAME=\"F1\"
TYPE=\"file\"></td></tr>\n");
out.write("\t\t\t\t\t<tr><td colspan=\"2\"><p align=\"right\"><INPUT
TYPE=\"submit\" VALUE=\"Send File\" ></p></td></tr>\n");
out.write(" <table>\n");
out.write(" </center> \n");
out.write(" </FORM>\n");
out.write(" \n");
out.write(" \n");
out.write(" </body>\n");
out.write("</html>\n");
}
catch (Exception e)
{
}
}
}
try {
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("<html>\n");
out.write(" <head>\n");
out.write(" <meta http-equiv=\"Content-Type\" content=\"text/html;
charset=UTF-8\">\n");
out.write(" <title>File upload</title>\n");
out.write(" </head>\n");
out.write(" <body bgcolor=\"#fdfdfd\">\n");
out.write("\n");
out.write(" <h1><font color=\"#black\">File Uploading...</h1>\n");
out.write(" ");
//to get the content type information from JSP Request Header
String contentType = req.getContentType();
//here we are checking the content type is not equal to Null and as well as the
passed data from mulitpart/form-data is greater than or equal to 0
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >=
0))
{
DataInputStream in = new DataInputStream(req.getInputStream());
//we are taking the length of Content type data
int formDataLength = req.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
//this loop converting the uploaded file into byte code
while (totalBytesRead < formDataLength)
{
byteRead = in.read(dataBytes, totalBytesRead,
formDataLength);
totalBytesRead += byteRead;
}
String file = new String(dataBytes);
//for saving the file name
String saveFile = file.substring(file.indexOf("filename=\"") + 10);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") +
1,saveFile.indexOf("\""));
int lastIndex = contentType.lastIndexOf("=");
String boundary = contentType.substring(lastIndex + 1,contentType.length());
int pos;
//extracting the index of file
pos = file.indexOf("filename=\"");
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
Page 20
ASP CODE
pos = file.indexOf("\n", pos) + 1;
int boundaryLocation = file.indexOf(boundary, pos) - 4;
int startPos = ((file.substring(0, pos)).getBytes()).length;
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
// creating a new file with the same name and writing the content in
new file
FileOutputStream fileOut = new FileOutputStream(saveFile);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
out.write("<Br><table border=\"2\"><tr><td><b><font color=\"#black\">You have
successfully upload the file by the name of:</b>\n");
out.write("\t\t");
out.println(saveFile);
out.write("</td></tr></table> ");
}
out.write("\n");
out.write("\n");
out.write(" </body>\n");
out.write("</html>\n");
out.write("\n");
}
catch (Exception e)
{
}
}
}
text=text+"<NAME>Microsoft</NAME>";
text=text+"<POST>Manager</POST>";
text=text+"<SALARY>50000</SALARY>";
text=text+"<BRANCH>Computer</BRANCH>";
text=text+"</COMPANY>";
text=text+"<COMPANY>";
text=text+"<NAME>Infosys</NAME>";
text=text+"<POST>Clerk</POST>";
Page 21
ASP CODE
text=text+"<SALARY>10000</SALARY>";
text=text+"<BRANCH>Electrical</BRANCH>";
text=text+"</COMPANY>";
text=text+"<COMPANY>";
text=text+"<NAME>GSFC</NAME>";
text=text+"<POST>Manager</POST>";
text=text+"<SALARY>25000</SALARY>";
text=text+"<BRANCH>Computer</BRANCH>";
text=text+"</COMPANY>";
text=text+"<COMPANY>";
text=text+"<NAME>ONGC</NAME>";
text=text+"<POST>Manager</POST>";
text=text+"<SALARY>35000</SALARY>";
text=text+"<BRANCH>Computer</BRANCH>";
text=text+"</COMPANY>";
text=text+"</INFO>";
document.getElementById("NAME1").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[0].getElementsByTagName("NAME")[0].childNodes
[0].nodeValue;
document.getElementById("POST1").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[0].getElementsByTagName("POST")[0].childNodes
[0].nodeValue;
document.getElementById("SALARY1").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[0].getElementsByTagName("SALARY")[0].childNod
es[0].nodeValue;
document.getElementById("BRANCH1").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[0].getElementsByTagName("BRANCH")[0].childNod
Page 22
ASP CODE
es[0].nodeValue;
document.getElementById("NAME2").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[1].getElementsByTagName("NAME")[0].childNodes
[0].nodeValue;
document.getElementById("POST2").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[1].getElementsByTagName("POST")[0].childNodes
[0].nodeValue;
document.getElementById("SALARY2").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[1].getElementsByTagName("SALARY")[0].childNod
es[0].nodeValue;
document.getElementById("BRANCH2").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[1].getElementsByTagName("BRANCH")[0].childNod
es[0].nodeValue;
document.getElementById("NAME3").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[2].getElementsByTagName("NAME")[0].childNodes
[0].nodeValue;
document.getElementById("POST3").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[2].getElementsByTagName("POST")[0].childNodes
[0].nodeValue;
document.getElementById("SALARY3").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[2].getElementsByTagName("SALARY")[0].childNod
es[0].nodeValue;
document.getElementById("BRANCH3").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[2].getElementsByTagName("BRANCH")[0].childNod
es[0].nodeValue;
document.getElementById("NAME4").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[3].getElementsByTagName("NAME")[0].childNodes
[0].nodeValue;
document.getElementById("POST4").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[3].getElementsByTagName("POST")[0].childNodes
[0].nodeValue;
document.getElementById("SALARY4").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[3].getElementsByTagName("SALARY")[0].childNod
es[0].nodeValue;
document.getElementById("BRANCH4").innerHTML=
xmlDoc.getElementsByTagName("COMPANY")[3].getElementsByTagName("BRANCH")[0].childNod
es[0].nodeValue;
}
</script>
</head>
<body onload="parseXML()">
Page 23
ASP CODE
<p>
<TABLE BORDER=1 BORDERCOLOR=BLUE ALIGN=CENTER>
<CAPTION>INFORMATION ABOUT COMPANIES </CAPTION>
<TR>
<TH>COMPANY NAME</TH> <TH>POST</TH>
<TH> SALARY </TH> <TH>BRANCH</TH>
<TR>
<TD>
<span id="NAME1"></span><br />
</TD>
<TD>
<span id="POST1"></span><br />
</TD>
<TD>
<span id="SALARY1"></span><br />
</TD>
<TD>
<span id="BRANCH1"></span><br />
</TD>
</TR>
<TR>
<TD>
<span id="NAME2"></span><br />
</TD>
<TD>
<span id="POST2"></span><br />
</TD>
<TD>
<span id="SALARY2"></span><br />
</TD>
<TD>
<span id="BRANCH2"></span><br />
</TD>
</TR>
</TR>
<TD>
</b> <span id="NAME3"></span><br />
</TD>
<TD>
<span id="POST3"></span><br />
</TD>
<TD>
<span id="SALARY3"></span><br />
Page 24
ASP CODE
</TD>
<TD>
<span id="BRANCH3"></span><br />
</TD>
</TR>
<TR>
<TD>
<span id="NAME4"></span><br />
</TD>
<TD>
<span id="POST4"></span><br />
</TD>
<TD>
<span id="SALARY4"></span><br />
</TD>
<TD>
<span id="BRANCH4"></span><br />
</TD>
</TR>
</p>
</body>
</html>
###################################### servlet admin valid code
##################################
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
Page 25
ASP CODE
try
{
String connectionURL =
"jdbc:mysql://localhost:3306/consultancy?user=root;password=root";
connection=DriverManager.getConnection(connectionURL);
}
catch(SQLException e)
{
out.println("Can't connect to database");
}
try
{
Statement smt=connection.createStatement();
String sql="SELECT * FROM admin";
String vusername=req.getParameter("username");
String vpassword=req.getParameter("password");
session.setAttribute("username",vusername);
session.setAttribute("password",vpassword);
ResultSet rs=smt.executeQuery(sql);
boolean flag=false;
while (rs.next())
{
String dusername = rs.getString("username");
String dpassword = rs.getString("password");
if ( vusername.equals(dusername) &&
vpassword.equals(dpassword) )
{
out.println("<html>");
out.println("<BODY
bgColor=#fdfdfd>");
out.println("<p><p><p>");
out.println("<META
HTTP-EQUIV=\"refresh\";
content=\"2;url=http://localhost:8080/bugs_servlet/Adminmenu.html\">");
out.println("<center><h1>Login
Successful !</h1>");
out.println("</center>");
out.println("</body></HTML>");
flag=true;
break;
}
}
if(!flag)
{
out.println("<html>");
out.println("<BODY bgColor=#fdfdfd>");
out.println("<p><p><p>");
out.println("<META HTTP-EQUIV=\"refresh\";
content=\"2;url=http://localhost:8080/bugs_servlet/Administrator.html\">");
out.println("<center><h1>Login Unsuccessful
!</h1>");
out.println("</center>");
out.println("</body></HTML>");
}
}
catch (Exception e)
Page 26
ASP CODE
{
out.println("some error");
}
try
{
connection.close();
}
catch(SQLException e)
{
out.println("Can't Dis-connect from database");
}
}
}
Page 27