<script language="JavaScript">
function validate()
{
if(document.myform.f_name.value== ""
||document.myform.l_name.value== ""
||document.myform.address.value== ""
||document.myform.id.value== "")
{
alert("Please complete all the entries ,try again?")
return false;
}
<!-- isNaN function is for checking non numberic id(s)-->
if(isNaN(document.myform.id.value)== true)
{
alert(" id must be numberic?")
return false;
}
document.myform.submit()
return true;
}
</script>
</HEAD>
<BODY>
<FORM action="Insertdata.cfm" method="POST" id=form1 name=form1>
<Center>
<TABLE WIDTH="35%" BORDER=1 CELLSPACING=1 CELLPADDING=1>
<TR>
<TD>First Name<input type="text" Name="f_name" size="10"> </TD>
<TD>Last Name<input type="text" Name="l_name" size="10"> </TD>
</TR>
<TR>
<TD>Address<input type="text" Name="address" size="10"> </TD>
<TD>ID<input type="text" Name="id" size="5"> </TD>
</TR>
<TR>
<TD><input type="button" Name="submit" value="Add" size="10" onClick="validate();"> </TD>
</TR>
</TABLE>
</center>
</FORM>
</BODY>
</HTML> Top
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>INSEERT INFORMATION</TITLE>
</HEAD>
<!-- sp_insert this is stored procedure which I created in SQL Server 2000-->
<CFSTOREDPROC PROCEDURE="sp_insert" datasource="tariqch" username="administrator" password="admin" Returncode="YES">
<cfprocparam type="in" CFSQLTYPE="CF_SQL_CHAR" DBVARNAME="@F_NAME" VALUE="#form.F_NAME#">
<cfprocparam type="in" CFSQLTYPE="CF_SQL_CHAR" DBVARNAME="@L_NAME" VALUE="#form.L_NAME#">
<cfprocparam type="in" CFSQLTYPE="CF_SQL_CHAR" DBVARNAME="@ADDRESS" VALUE="#form.ADDRESS#">
<cfprocparam type="in" CFSQLTYPE="CF_SQL_INTEGER" DBVARNAME="@ID" VALUE="#form.ID#">
<CFPROCRESULT NAME="BASICINFO">
</CFSTOREDPROC>
<!--Syntax of stored procedurs which I created in SQL server 2000-->
Create procedure sp_insert
( @f_name char(10),
@l_name char(10),
@address char(10),
@id numeric(9)
)
As
Insert into tblbiodata
values(@f_name,@l_name,@address,@id)
<b> <font color="#800000">A new record with id</font><font color="blue">
<cfoutput>#Id#</cfoutput></font><font color="maroon"> has been added</font></b><br><br>
<table>
<tr>
<th bgcolor="#ffffff">First Name</th>
<th bgcolor="#00ffff">Last Name</th>
<th bgcolor="#00ffff">Address</th>
<th bgcolor="#00ffff">ID</th>
</tr>
<CFOUTPUT>
<tr> <td>#F_NAME#</td></tr>
<tr> <td>#L_NAME#</td></tr>
<tr> <td>#ADDRESS#</td></tr>
<tr> <td>#ID#</td></tr>
</table>
</CFOUTPUT>
</body>
</HTML> Top
Database Driven Banking Application using Session Variables
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Date: April 24,2003
<html>
<head>
<title>Login</title>
</head>
<body bgcolor="">
<form action="request.cfm" method="post" name="frm1">
<div align="center"><strong><font size="+4" color="#800000"><strong>Log In</strong></font></strong></div>
<div align="center">
<table width="35%" border="1" cellpadding="2" cellspacing="4" bgcolor="#ffff00">
<tr>
<td>
Customer Name<input type="Text" name="custname" size="10">
Password
<input type="password" name="custpwd" size="10">
</td>
</tr>
<tr>
<td>
<div align="center">
<input type="submit" name="btnsubmit" value=" Submit" size="10" >
</div>
</td>
</tr>
</table></div>
</form>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>approval page</title>
</head>
<body>
<!--- Check to see if the session variable exists, if not set it. --->
<CFPARAM name="session.custpwd" default="N">
<CFPARAM name="session.custname" default="N">
<!--- Check to see if the session variable exists, if not redirect them to the login page --->
<CFIF IsDefined("session.custpwd") EQUAL "No"> <CFLOCATION URL="/login.cfm"></CFIF>
<!--this will display the error message if nothing was entered-->
<cfif form.custpwd is "" or form.custname is "" >
<script language="javascript">
alert("Error: You left something blank,so try again??")
history.go(-1);
</script>
</cfif>
<cfquery name="checkuser" datasource="tariqch">
Select * from custlogin
where custpwd=#custpwd# and custname='#custname#'
</cfquery>
<cfif form.custpwd is NOT checkuser.custpwd and form.custname is NOT checkuser.custname>
<script language="javascript">
alert("Error: You do not exist in the database,check your name and password??")
history.go(-1);
</script>
<cfelse>
<cfset Session.custname="#checkuser.custname#">
<cfset Session.custpwd="#checkuser.custpwd#">
</cfif>
<cfoutput query="checkuser">
<font size="10" color="darkblue">Hi you just logged in and your name is #session.custname#you will be able to see some useful stuff</font>
<div align="center">
<a href="checking.cfm?custpwd=#session.custpwd#">Checking Account</a><br>
<a href="Saving.cfm?custpwd=#session.custpwd#">Saving Account</a>
</div>
</cfoutput>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<h1>This is your Saving Account information</h1>
<cfquery name="qsaving" datasource="tariqch">
Select custlogin.custname,tblsaving.amount,tblsaving.date
from tblsaving ,custlogin
where tblsaving.id = #session.custpwd#
and custlogin.custname = '#session.custname#'
</cfquery>
<div align="center">
<table cellpadding="4" cellspacing="4">
<Tr bgcolor="#ffff00">
<th>Name</th><th>Amount</th><th>Date</th>
</tr>
<tr>
<cfoutput query="qsaving">
<td>#custName#</td>
<td> #amount# </td>
<td>#date#</td>
</tr>
<tr><td><a href="checking.cfm?custpwd=#custpwd#">Checking Account</a></td></tr>
</cfoutput>
</table></div>
</body>
</html>
Top Inserting Data using Cold Fusion,SQL Server 2000,IIS 5.0 and SQL and etc.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="javascript">
function Chkblank()
{
if
( document.frm.fname.value == "" )
{
alert(" You left first name blank?")
return false
}
if( document.frm.lname.value == "" )
{
alert(" You left last name blank?")
return false
}
if(document.frm.city.value == "" )
{
alert(" You left city name blank?")
return false
}
if( document.frm.state.value == "" )
{
alert(" You left state name blank?")
return false
}
if(document.frm.id.value == "")
{
alert(" You left id number blank?")
return false
}
else
document.frm.submit()
return true
}
</script>
<title>Inserting Records</title>
</head>
<body> Top
<form action="Insert.cfm" Method="post" name="frm">
<table bgcolor="lightyellow" width="40%" height="25%" align="center" border="0">
<tr>
<td>First Name<input type="text" Name="fname" size="8">
Last Name <input type="text" Name="lname" size="8"></td>
</tr>
<tr>
<td>City<input type="text" Name="city" size="8" width="14">
State<input type="text" Name="state" size="8"></td>
</tr>
<tr>
<td>Id<input type="text" Name="id" size="8"></td>
</tr>
<tr>
<td>
<input type="button" value="Insert" onclick="Chkblank()">
<input type="reset" Value="Clear"></td>
</tr>
</table>
</form>
</body>
</html> Top
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Insert data</title>
</head>
<body>
<cfquery name="qinsert" datasource="info">
Insert into tblinfo (fname,lname,city,state,id)
values('#fname#','#lname#','#city#','#state#',#id#)
</cfquery>
<strong><font size="+1" color="#800000">Inserted record</font>:</strong>
<table align="center" bgcolor="lightyellow" cellspacing="2" cellpadding="2" width="41%" border="2">
<tr>
<th>First name</th>
<th>Last Name</th>
<th>City</th>
<th>State</th>
<th>ID</th></font>
</tr>
<cfoutput>
<tr>
<td>#fname#</td>
<td>#lname#</td>
<td>#city#</td>
<td>#state#</td>
<td>#id#</td>
</tr>
</cfoutput>
</table>
<A href="showRecords.cfm">Show me all records</A>
</body>
</html> TopDeleting Database Records
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Delete Records</title>
</head>
<body>
<cfquery name="qfordelete" datasource="info">
Select * from tblinfo
where id = #id#
</cfquery>
<cfoutput query="qfordelete">
<form>
<table border="1">
<tr>
<td><input type="text" Name="fname" Value="#fname#"></td>
<td><input type="text" Name="lname" Value="#lname#"></td>
</tr>
<tr>
<td><input type="text" Name="city" Value="#city#"></td>
<td><input type="text" Name="state" Value="#state#"></td>
</tr>
<tr>
<td><input type="text" Name="id" Value="#id#"></td>
</tr>
<tr>
<td><input type="submit" Name="btnsubmit" Value="Delete"></td></tr>
</table>
</form>
</cfoutput>
<cfquery datasource="info" name="qdelete">
Delete from tblinfo
where id =#id#
</cfquery>
</body>
</html>
Top
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Perform update</title>
</head>
<body>
<cfquery datasource="info" name="qup">
UPDATE tblinfo
Set fname= '#fname#',
lname= '#lname#',
city = '#city#',
state = '#state#'
WHERE id = #id#
</cfquery>
</body>
</html> Top Creating Different Access levels using Session Variables
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
Friday, January 16, 2004<br>
<HEAD>
<strong><font color="#800000">login form</font></strong>
</HEAD>
<BODY>
<FORM action="login_sys.cfm" method="POST" name="myform">
<Center>
<TABLE WIDTH="39%" height="20%" BORDER=0 CELLSPACING=2 CELLPADDING=2 bgcolor="lightyellow">
<TR>
<TD>User Id<input type="password" Name="userid" size="10"> </TD>
<TD>User<input type="text" Name="fname" size="10"> </TD>
</TR>
<TR>
<TD align="right"><input type="submit" Name="btnSubmit" value="Login">
<input type="reset" value="Clear">
</TD>
</TR>
</TABLE>
</center>
</FORM>
</BODY>
</HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Friday, January 16, 2004
<html>
<head>
<title>Welcome to the system</title>
</head>
<body>
<!--- if any field is blank then warn the user--->
<cfif form.userid is "" or form.fname is "" >
<script language="javascript">
alert("Error: You left something blank,so try again??")
history.go(-1);
</script>
</cfif>
<cfquery name="qryusers" datasource="tariqch">
Select * from tblNusers
where userid=#userid# and fname='#fname#'
</cfquery>
<!--- if there is not record send the user back to login screen--->
<cfif #qryusers.recordcount# is 0>
<script>
alert(" no record found")
history.go(-1)
</script>
<cfelse>
<CFSET session.userid="#qryusers.userid#">
<CFSET session.fname="#qryusers.fname#">
<CFSET session.title="#qryusers.title#">
<CFSET session.admin="#qryusers.admin#">
</cfif>
<cfoutput>
<cfif session.admin equal 1>
<font size="10" color="darkblue">You logged in as a #session.fname#,and your title is: #session.title# <br>
and you are an administrator and you can view the followings<br>
<a href="www.yahoo.com">Yahoo</a></font>
<!--- if user is not admin then send the user back to user menu--->
<cfelseif session.admin eq 0>
<script>
alert(" sorry,you r not an admin,so u can not access this menu,u will be send to user menu? ")
document.location="userMenu.cfm"
</script>
</cfif>
</cfoutput>
Top
</body>
</html>