I have the following script which insert the data after the user choose yes or no. But when I click on no, the script still insert the data. I could not find out the reason why. Anyone can help?
Code:
<%
DIM NAME, YEAR, RATING
NAME = Request.Form("NAME")
YEAR = Request.Form("YEAR")
RATING = Request.Form("RATING")
sqlcheck="select * from subdb_subcon_rating WHERE NAME LIKE '"&NAME&"' AND YEAR LIKE '"&YEAR&"'"
Set check = OraDatabase.Execute(sqlcheck)
if check.EOF then
sql="INSERT into subdb_subcon_rating(NAME, YEAR, RATING) values ('"&NAME&"','"&YEAR&"','"&RATING&"')"
Set objRS = OraDatabase.Execute(sql)
%>
<script language="VBScript">
MsgBox "Records have been inserted",64,"Alert"
window.location= "input_records.asp"
</script>
<%
else
%>
<script language="VBScript">
returnvalue=MsgBox ("Records already exist in Database!"& vbCrLf &"Do you want to overwrite the records?",36,"Alert")
If returnvalue=6 Then
<%
OraDatabase.Execute("UPDATE subdb_subcon_rating SET RATING = '"&RATING&"' WHERE NAME LIKE '"&NAME&"' AND YEAR LIKE '"&YEAR&"'")
%>
MsgBox "Records have been inserted",64,"Alert"
window.location="input_records.asp"
end if
if returnvalue=7 then
MsgBox "Records NOT inserted",64,"Alert"
history.go(-1)
End If
</script>
<%
end if
%>