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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP form edit error - please help

Status
Not open for further replies.

tadisaus2

Programmer
Mar 9, 2007
1
US
Hello,

I am trying to print out some text "Thanks for editing..." after the user edit the form from database, but it does not work. After I edit this form, it showed a blank page. When I check at the edited text, it was there. I meant, the form worked, but it does not say "Thanks for editing..." or any text.
Can you please show me how to print out "thanks for editing..." after the user edit this form.
Thanks.

<%
On Error Resume Next
Function ChkString(string)
If string = "" Then string = " "
ChkString = Replace(string, "'", "'")
End Function

dim objMail, BodyText, conn1, strConnect
dim FNAme, LName, MName, SSN, Email
Dim strErrorEmail
strErrorEmail = "test@yahoo.com"
' Receiving values from Form
FNAme = ChkString(Request.Form("First_Name"))
LName = ChkString(Request.Form("Last_Name"))
MName = ChkString(Request.Form("Middle_Name"))
SSN = ChkString(Request.Form("SSN"))
Email = ChkString(Request.Form("Email_Address"))

strConnect = ""
set conn1 = server.CreateObject("ADODB.Connection")
conn1.ConnectionString=strConnect
conn1.ConnectionTimeout=30
conn1.open

if request.QueryString("type") = "D" then
sql_update = "DELETE FROM Echoes WHERE Email_Address = '" & Email & "'"
else
sql_update = "UPDATE Echoes SET First_Name = '" & FName & "', Last_Name = '" & LName & "', Middle_Name = '" & MName & "', SSN = '" & SSN & "', Email_Address = '" & email & "' WHERE Email_Address = '" & email & "'"
end if

conn1.Execute sql_update
%>
<%
If Err.Number <> 0 Then
Response.Clear
set objMail=Server.CreateObject("CDONTS.Newmail")
IsObj= isobject(objMail)
if IsObj Then
BodyText = "Page Error" & Chr(13) & Chr(13)
BodyText = BodyText & "Error Number: " & Err.Number & Chr(13)
BodyText = BodyText & "Error Description: " & Err.Description & Chr(13)
BodyText = BodyText & "Source: " & Err.Source & Chr(13) & Chr(13)
' BodyText = BodyText & "LineNumber: " & Err.Line & Chr(13) & Chr(13)
BodyText = BodyText & "First Name: " & FName & Chr(13)
BodyText = BodyText & "Middle Initial: " & MName & Chr(13)
BodyText = BodyText & "Last Name: " & LName & Chr(13)
BodyText = BodyText & "Social Security Number: " & SSN & Chr(13)
BodyText = BodyText & "Email: " & Email & Chr(13)
objMail.From="test@hqda.army.mil"
' objMail.To = "test1@hqda.army.mil"
objMail.To = "test3@hqda.army.mil"
objMail.Subject = "Error with test G-1 Echoes Edit/Delete"
objMail.Body = BodyText
objMail.Send
Set objMail = Nothing
else
strMsg = "The email failed. Please try again."
end if

response.Write("<br>sql statement: " & sql_update)

conn1.Close
Set conn1 = Nothing
%>
<div id="wrap">
<div id="main">
<div id="content">
<h3 align="center">Edit/Delete</h3><p>error occurred.</p>
</div>
</div>
<%
Else
Response.Redirect("register.asp")
End If
%>
</div>
 
At this part here:
Code:
<%
    Else 
        Response.Redirect("register.asp")  
    End If 
%>

You may want to redo the entire HTML part like so
Code:
<div id="wrap"> 
    <div id="main">
        <div id="content">
            <h3 align="center">Edit/Delete</h3><p>error occurred.</p>
        </div>
    </div>
[!]</div>[/!]    
<%
    Else 
       Response.Write("<div>Thanks for editing...</div>"); 
       Response.Write("<a href="register.asp">Click here to Continue</a>"); 
    End If 
%>

This will make the user have to click on an anchor to redirect, but it will show your message. I tried to look for a .Sleep command, but couldn't find any, not with VBScript ASP.

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top