Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

want to add an error message on submit 2

Status
Not open for further replies.

micawber

Programmer
Dec 10, 2002
71
GB
I have a working asp page that collects an entry and checks it with a database then shows the results.
I want to show an error message when nothing or a none matching entry is submitted.
Can anyone help?
Here the relevant code...
Code:
<%
dim str_PhoneNumber, sql, rs
  str_PhoneNumber = Request.Form("input")
  If str_PhoneNumber <> "" Then
   sql = "SELECT * FROM dbo.NUMBERS WHERE REPLACE([phone1], ' ', '') = REPLACE('" & str_PhoneNumber & "', ' ', '');"
      set rs=Server.CreateObject("ADODB.Recordset")
   rs.Open sql, conn

do until rs.EOF
   response.write("<table width='100%' cellspacing='0' cellpadding='2' border='0'>")	
   response.write("<tr>")
   response.write("<td>" & "Number Inputted" & "</td>")
   response.write("<td>" & "Alternative 1" & "</td>")
   response.write("<td>" & "Alternative 2" & "</td>")
   response.write("</tr>")
   response.write("<tr>")
   response.write("<td>" & rs.fields("phone1") & "</td>")
   response.write("<td>" & rs.fields("phone2") & "</td>")
   response.write("<td>" & rs.fields("phone3") & "</td>")
   response.write("</tr>")
   response.write("</table>")   
   rs.MoveNext
loop
rs.close
conn.Close
set rs=Nothing
set conn=Nothing%>
<%  end if %>
 
[tt]
Response.Write "<table width='100%' " _
& "cellspacing='0' " _
& "cellpadding='2' " _
& "border='0'>" & vbCrLf
if rs.EOF then
Response.Write "<tr><td colspan='3'>no dice</td></tr>" & vbCrLf
else
do until rs.EOF
[make other rows here]

rs.MoveNext
loop
end if
Response.Write "</table>" & vbCrLf
[/tt]
 
I see.

You do the match. If there is no match, what you get back is an empty recordset. First thing, you do a check with rs.EOF to see if that is what you have and write the error if you do.

Cool.

 
Is it possible using this code that, as well as giving the error message it sends an email to a destination with the form entry that cannot be found?
Thanks!
 
Thanks sheco,
I am familiar with the concept of sending an email via a form in asp.
The problem I have is stitching it into the code I've used and if it is even possible.
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top