I'm asking for adding a record to the database which that's record already available in the database. In this case an error must dislplay for the user to tell him that your record is already availble.....
this is my code and I tried
Code:
<HTML><HEAD>
<%
Function ChkString(str)
str = replace(str, "<", "<", 1, -1, 1)
str = replace(str, ">", ">", 1, -1, 1)
ChkString = str
End Function
ModemNo =Request.form("ModemNo")
DeptCode = trim(ChkString(Request.form("DeptCode")))
DeptName = trim(ChkString(Request.form("DeptName")))
CSLNo = trim(ChkString(Request.form("CSLNo")))
Area = trim(ChkString(Request.form("Area")))
SiteName = trim(ChkString(Request.form("SiteName")))
SiteNo = trim(ChkString(Request.form("SiteNo")))
NC = trim(ChkString(Request.form("NC")))
CT = trim(ChkString(Request.form("CT")))
IC = trim(ChkString(Request.form("IC")))
BU = trim(ChkString(Request.form("BU")))
ConnString = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/database/wardialer.mdb")
set my_conn= Server.CreateObject("ADODB.Connection")
my_Conn.Open ConnString
set rscheck = my_conn.Execute ("Select ModemNo from Table1 where ModemNo =" & ModemNo & "")
if rscheck.eof then
been_here_before="No"
end if
RScheck.close
set rs = server.CreateObject("adodb.recordset")
if been_here_before="No" then
sql ="select * from Table1"
RS.open Sql,my_conn,1,3
RS.AddNew
RS("ModemNo")=ModemNo
RS("DeptCode")=DeptCode
RS("DeptName")=DeptName
RS("CSLNo")=CSLNo
RS("Area")=Area
RS("SiteName")=SiteName
RS("SiteNo")=SiteNo
RS("NC")= NC
RS("CT")= CT
RS("IC")= IC
RS("BU")= BU
'RS("date")= now()
RS.update
%>
</HEAD>
<body bgcolor="#f4f4f4">
<div align="center"><font color="#000000" size="2" face="Verdana"> <br>
<br>
Has Been Processed!! <br>
modem number is : <%=ModemNo%> , and your depatment is : <%=DeptCode%>
</font> </div>
<p align="center"><font color="#000000"><a href="main1.asp"><font face="Verdana" size="2">Go
to main page</font> </a> </font></p>
<font color="#000000">
<%
else
%><center>
<div align="center"><font color="#000000" size="2" face="Verdana">Your have already
add this modem<br>
Please add another modem. </font> </div>
<p align="center"><font color="#000000"><a href="addNew.asp"><font face="Verdana" size="2">Sign
up Again! </font> </a>
<%
end if
rs.close
my_conn.Close
set my_conn = nothing
set rs = nothing
%>
</font></P>
</body></HTML>
There seems to be some dead code in there. By that i mean code that is not used, but just sits there.. The variable named 'sql', for example.
Also, conventionally, its good practise to dimension all variables all variables at the top of youre script. And some indenting wouldnt hurt, either. Just for readability and debugging.
Are you receiving an error when the script is executed?
Finally I have confirm2.asp
[CODE]
finally confirm2.asp
Code:
<HTML><HEAD>
<%
Function ChkString(str)
str = replace(str, "<", "<", 1, -1, 1)
str = replace(str, ">", ">", 1, -1, 1)
ChkString = str
End Function
ModemNo = trim(ChkString(Request.form("ModemNo")))
DeptCode = trim(ChkString(Request.form("DeptCode")))
DeptName = trim(ChkString(Request.form("DeptName")))
CSLNo = trim(ChkString(Request.form("CSLNo")))
Area = trim(ChkString(Request.form("Area")))
SiteName = trim(ChkString(Request.form("SiteName")))
SiteNo = trim(ChkString(Request.form("SiteNo")))
NC = trim(ChkString(Request.form("NC")))
CT = trim(ChkString(Request.form("CT")))
IC = trim(ChkString(Request.form("IC")))
BU = trim(ChkString(Request.form("BU")))
ModemNoOK = IsNumeric(ModemNo)
CSLNoOK = IsNumeric(CSLNo)
SiteNoOK = IsNumeric(SiteNo)
if ModemNoOK = FALSE then
response.write "You didn't enter a modem number as a number. Please try again."
else
if CSLNoOK = FALSE then
response.write "You didn't enter the csl number as a number. Please try again."
else
if ModemNo = "" then
Response.Write "Please Enter Your Modem number<br>"
else
if NC <> "no" and NC <> "yes" then
Response.Write "Please Enter network Connectivity either yes or no <br>"
else
if CT <> "in" and CT <> "out" and CT <> "both" then
Response.Write "Please Enter connection type either in, out or both <br>"
else
if IC <> "no" and IC <> "yes" then
Response.Write "Please Enter Internet Connection either yes or no <br>"
else
if BU <> "no" and BU <> "yes" then
Response.Write "Please Enter Busness Use either yes or no <br>"
else
%>
</HEAD>
<BODY bgColor="#f4f4f4" >
<P align=center><font
color=#000000>Please verify if all your info you supplied is correct! If not hit
back and correct.</font></P>
<center>
<table border="0" cellpadding="2" cellspacing="3" width="400">
<tr>
<td ><font face="Verdana" size="2" color=#000000>ModemNo :</font></td>
<td ><%=ModemNo%> </td>
</tr>
<tr>
<td ><font face="Verdana" size="2" color=#000000>DeptCode :</font></td>
<td ><%=DeptCode%> </td>
</tr>
<tr>
<td ><font face="Verdana" size="2" color=#000000>DeptName :</font></td>
<td ><%=DeptName%> </td>
</tr>
<tr>
<td ><font face="Verdana" size="2" color=#000000>CSLNo :</font></td>
<td ><%=CSLNo%> </td>
</tr>
<tr>
<td ><font face="Verdana" size="2" color=#000000>Area :</font></td>
<td ><%=Area%> </td>
</tr>
<tr>
<td ><font face="Verdana" size="2" color=#000000>SiteName :</font></td>
<td ><%=SiteName%> </td>
</tr>
<tr>
<td ><font face="Verdana" size="2" color=#000000>SiteNo :</font></td>
<td ><%=SiteNo%> </td>
</tr>
<tr>
<td ><font face="Verdana" size="2" color=#000000>NC :</font></td>
<td ><%=NC%> </td>
</tr>
<tr>
<td ><font face="Verdana" size="2" color=#000000>CT :</font></td>
<td ><%=CT%> </td>
</tr>
<tr>
<td ><font face="Verdana" size="2" color=#000000>IC :</font></td>
<td ><%=IC%> </td>
</tr>
<tr>
<td ><font face="Verdana" size="2" color=#000000>BU :</font></td>
<td ><%=BU%> </td>
</tr>
<tr>
<td ><font color="#000000"> </font></td>
<td > <form action=add.asp method="post" ID=Form1>
<input type=hidden name="ModemNo"value="<%=ModemNo%>" ID=Hidden1>
<input type=hidden name="DeptCode" value="<%=DeptCode%>" ID=Hidden2>
<input type=hidden name="DeptName" value="<%=DeptName%>" ID=Hidden3>
<input type=hidden name="CSLNo" value="<%=CSLNo%>" ID=Hidden4>
<input type=hidden name="Area" value="<%=Area%>" ID=Hidden5>
<input type=hidden name="SiteName" value="<%=SiteName%>" ID=Hidden6>
<input type=hidden name="SiteNo" value="<%=SiteNo%>" ID=Hidden7>
<input type=hidden name="NC" value="<%=NC%>" ID=Hidden8>
<input type=hidden name="CT" value="<%=CT%>" ID=Hidden9>
<input type=hidden name="IC" value="<%=IC%>" ID=Hidden10>
<input type=hidden name="BU" value="<%=BU%>" ID=Hidden11>
<input type=submit value="Confirm" ID=Submit1>
</form></td>
</tr>
</table>
</center>
<%
end if
end if
end if
end if
end if
end if
end if
%>
</body>
</HTML>
Bookmarks