<%
strODBC = "Driver={MySQL};" & _
"Server=localhost;" & _
"Database=sistemkewangan;" & _
"Uid=root;" & _
"Pwd=;"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
pwdNama = request.Form("pwdNama")
pwdsoalan = request.Form("pwdsoalan")
pwdJawapan = request.Form("pwdJawapan")
Dim Objrs
set Objrs = Server.CreateObject("ADODB.Connection")
Objrs.Open strODBC
Dim Strsql
Strsql = "SELECT dKat1 FROM pendaftaran WHERE dNId = '" & pwdNama & "'"
Strsql = Strsql + " AND " & "dSoa = " & "'" & pwdsoalan & "'"
Strsql = Strsql + " AND " & "dJa = " & "'" & pwdJawapan & "'"
set rst = Objrs.Execute(Strsql)
if rst.eof then
Set rst = Nothing
Set Objrs = Nothing
response.write "<script language=JavaScript>"
response.write "alert('Tiada Nama Id anda!!');"
response.write "location.replace('MainPage.asp');"
response.write "</script>"
end if
%>
<html>
<head>
<title>Kembali Katalaluan</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
enableJS();
is_form_submited=1;
return true;
}
</script>
</head>
<body bgcolor="#FFFFFF">
<h3 align="center"> </h3>
<p align="center"><font size="5" face="Arial, Helvetica,
sans-serif"><strong>DAPATKAN
KEMBALI KATALALUAN</strong></font></p>
<p align="center"> </p>
<form action=""name="kemkatalaluanForm" method="post" target="_parent">
<p> </p>
<table width="56%" border="0" align="center">
<tr>
<td width="19%"><strong><font color="#FF3300" size="2"
face="Arial, Helvetica, sans-serif">NAMA
ID </font></strong></td>
<td width="81%"><input name="pwdNama" type="text" id="pwdNama"
size="30" maxlength="50"></td>
</tr>
<tr>
<td><strong><font color="#FF3300" size="2" face="Arial, Helvetica,
sans-serif">SOALAN</font></strong></td>
<td><select name="pwdsoalan" id="pwdsoalan">
<option value="1">Apakah nama binatang kesayangan
anda?</option>
<option value="2">Apakah nama sekolah pertama anda
belajari?</option>
<option value="3">Siapakah pahlawan anda gemari semasa
kecil?</option>
<option value="4">Apakah kegemaran anda masa lalu?</option>
<option value="5">Apakah pasukan sukan yang anda
gemari?</option>
<option value="6">Apakah kereta/basikal pertama anda?</option>
<option value="7">Di mana anda jumpa isteri anda pada pertama
kali?</option>
</select></td>
</tr>
<tr>
<td><strong><font color="#FF3300" size="2" face="Arial, Helvetica,
sans-serif">JAWAPAN</font></strong></td>
<td><input name="pwdJawapan" type="text" id="pwdJawapan" size="53"
maxlength="52"
onChange="javascript:this.value=this.value.toUpperCase();"></td>
</tr>
<tr>
<td> </td>
<td><input name="pwdId" type="hidden" id="pwdId"></td>
</tr>
</table>
<p align="left"><strong><font size="+2" face="Arial, Helvetica,
sans-serif">
</font><font face="Arial, Helvetica, sans-serif">Katalaluan Anda :
</font><font size="+2" face="Arial, Helvetica,
sans-serif"> <%=rst("dKat1")%></font></strong></p>
<font
face="Arial, Helvetica, sans-serif"><strong>
Kembali ke Login, sila klik <a
href="http://localhost/remote_sistemKewangan/MainPage.asp">sini</a>
</strong></font>
<p align="left"> </p>
</form>
<p align="center"> </p>
<p align="center"><strong><font size="+2" face="Arial, Helvetica,
sans-serif">
</font></strong></p>
</body>
</html>
<%
rst.Close()
Set rst = Nothing
%>
pls solve my problem....i cant get back password from database
MySQL.Thank you!!!
Mike Brind - 25 Apr 2006 09:10 GMT
> <%
> strODBC = "Driver={MySQL};" & _
[quoted text clipped - 18 lines]
> Strsql = Strsql + " AND " & "dSoa = " & "'" & pwdsoalan & "'"
> Strsql = Strsql + " AND " & "dJa = " & "'" & pwdJawapan & "'"
At this point, enter the following:
response.write Strsql
response.end
then post the result from your browser here.
--
Mike Brind
Chris Wu - 25 Apr 2006 12:02 GMT
SELECT dKat1 FROM pendaftaran WHERE dNId = 'kokseng' AND dSoa = '1' AND
dJa = '-'
This sql query is the result in my browser.
Mike Brind - 25 Apr 2006 12:50 GMT
> SELECT dKat1 FROM pendaftaran WHERE dNId = 'kokseng' AND dSoa = '1' AND
> dJa = '-'
>
> This sql query is the result in my browser.
And does it give you any records if you run it against your database?
I suspect that it does not - which means that the code for rst.eof
runs, and within that, the recordset is set to nothing. Then you refer
to it again further down in your code, but by this time the object has
been destroyed.
You probably think that the javascript redirect would ensure that the
code lower down doesn't get run if rst.eof, but that's not how it
works. The whole page is parsed by the ASP engine from top to
bottom PRIOR to the resulting html being sent to the client. Client
side Javascript will not run until it has reached the client
(obviously).
I would change the If rst.eof code to this:
if rst.eof then
response.write "<script language=JavaScript>"
response.write "alert('Tiada Nama Id anda!!');"
response.write "location.replace('MainPage.asp');"
response.write "</script>"
Else
dKat1 = rst("dKat1")
end if
Set rst = Nothing
Set Objrs = Nothing
Then <%= dKat1 %> should go later in your script, and you will need to
delete the rst.Close()
Set rst = Nothing
at the bottom.
--
Mike Brind
Chris Wu - 25 Apr 2006 12:02 GMT
SELECT dKat1 FROM pendaftaran WHERE dNId = 'kokseng' AND dSoa = '1' AND
dJa = '-'
It is the result i get from my browser....