please! need help.....

sha_lini
sha_lini used Ask the Experts™
on
I have a search result page . One of the column is bid that giving user to make a bid on that item. User have to login before make a bid. Only valid or registered user can make the bid. So i use a popuplogin to make the validation.

My problem is now..

If valid user clik and make a bid one that item the page will bring the user to bid section that same with the record we want. That means if search result page ref_num =1 so after login the page have to bring user to bid page that ref_num for the page also 1.

Hope can understand.

This is my code..

a part of my search result page code that will bring user to popouplogin.
====================================
<td width="43">
     <div align="center"><img src="image/view.gif" width="30" height="15" onClick="javascript: showLoginScreen();">


popuplogin.asp
==============
<%@ Language=VBScript %>

<%option explicit%>

<%Response.Expires = -1%>

<html>
<head>

    <script language="JavaScript1.2">
   
         function checkFormAndSubmit() {
         
              var strError;
              strError = '';

              if (document.frmLogin.txtPassword.value.length == 0) {
                   strError = '\t Enter your password\n' + strError;
                   document.frmLogin.txtPassword.focus();
              }
              if (document.frmLogin.txtUserID.value.length == 0) {
                   strError = '\t Enter your login id\n' + strError;
                   document.frmLogin.txtUserID.focus();
              }
             
              if (strError.length != 0) {
                   alert('Please fill in the information required:\n\n' + strError);
              } else {
                   document.frmLogin.submit();
              }
         
         }

         function checkForEnterKeyToSubmit() {
         
              if (window.event && window.event.keyCode == 13) {
             
                   checkFormAndSubmit();
             
              }
             
         }
   
    </script>

</head>
<body onLoad="javascript: document.frmLogin.txtUserID.focus();" background="image/whte5.gif">
<form id="frmLogin" name="frmLogin" method="post" action="check.asp">
 <table border="0" bordercolor="blue" cellspacing="0" cellpadding="5">
         
         <%
         
         if len(session("remark")) <> 0 then
         
              Response.Write "<tr><td colspan=""2"">" & session("remark") & "</td></tr>"
         
         end if
         
         %>
         
         <tr>
              <td>user id:</td>
              <td><input type="text" size="20" maxlength="25" id="txtUserID" name="txtUserID" value="<%=session("userID")%>"></td>
         </tr>
         <tr><td colspan="2" height="15"></td></tr>
         <tr>
              <td>password:</td>
              <td><input type="password" size="20" maxlength="25" id="txtPassword" name="txtPassword" onKeyPress="javascript: checkForEnterKeyToSubmit();"></td>
         </tr>
         <tr>
     <td colspan="2" height="25">&nbsp; </td>
   </tr>
         <tr><td colspan="2" align="center"><input type="button" id="btnLogin" name="btnLogin" value=" login " class="button" onClick="javascript: checkFormAndSubmit();"></td></tr>
                   
    </table>

</form>

<%
session("remark") = ""
session("userID") = ""
session("password") = ""
%>

</body>
</html>

check.asp
=========
<%@ Language="VBScript" %>

<!--#include file="Clssfd.asp"-->

<% response.buffer=true %>

<%

dim strUserId
dim strPassword
dim allowLogin

strUserId = Request.Form("txtUserID")
strPassword = Request.Form("txtPassword")
id = request.querystring("property")

 
 Dim rsUsers
 set rsUsers = Server.CreateObject("ADODB.Recordset")
 strSQL = "SELECT * FROM customer WHERE login_ID = '" & strUserID & "' AND password = '" & strPassword & "';"
 rsUsers.Open strSQL, objConn
 
 If not rsUsers.EOF then        'User was found - check password
    If rsUsers("login_ID") = strUserID AND rsUsers("password") = strPassword then
        allowlogin=true

    else
     response.write request.querystring("ref_num")
        response.write("Login Fail")
        allowuser=false
    end if
   

  %>

  <html>
  <head>
       <script language="JavaScript1.2">
       
            function forwardMainScreen() {
           
               window.opener.document.location = 'bid.asp';
                 window.close();
                 
            }
       
       </script>
         
       </head>
  <body onload="javascript: forwardMainScreen();">
  </body>
 

    <%

else
   
    session("remark") = "Please provide valid user ID and Password"
    Response.write ("Login Fail")

end if


%>


Need help..>>

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
sha_lini,

To pass the record you can request.querystring method on your popup login.

In the example below... I make a sample loop assuming that i is bid idnumber record... You can change the for loop with your do while loop of your recordset... and change value of with your unique key of the bid item.

===================
<%@LANGUAGE="VBSCRIPT"%>

<script language="JavaScript1.2">
   
    function showLoginScreen(id_num) {
         var popup;

         wndLogin = window.open("popuplogin.asp?ref_num="+ id_num,"popup","resizable=yes, width=400, height=250");
     }
</script>

<%
for i = 1 to 3 %>
<tr>
     <td width="43">
       <div align="center"><img src="image/view.gif" width="30" height="15" onClick="javascript: showLoginScreen(<%=i%>);">
       </div>
   </td>
 </tr>
<%next%>
=======================


On the popup login I added a field that will show you that the variable is being pass to other page... You can make it as a hidden field and when you pass the user to check.asp

             <input type="hidden" name="hiddenField" value="<%=request.querystring("ref_num")%>">
             
==============popuplogin.asp

<%@ Language=VBScript %>
<%option explicit%>
<%Response.buffer = true%>

<%Response.Expires = -1%>

<html>
<head>

    <script language="JavaScript1.2">
   
         function checkFormAndSubmit() {
         
              var strError;
              strError = '';

              if (document.frmLogin.txtPassword.value.length == 0) {
                   strError = '\t Enter your password\n' + strError;
                   document.frmLogin.txtPassword.focus();
              }
              if (document.frmLogin.txtUserID.value.length == 0) {
                   strError = '\t Enter your login id\n' + strError;
                   document.frmLogin.txtUserID.focus();
              }
             
              if (strError.length != 0) {
                   alert('Please fill in the information required:\n\n' + strError);
              } else {
                   document.frmLogin.submit();
              }
         
         }

         function checkForEnterKeyToSubmit() {
         
              if (window.event && window.event.keyCode == 13) {
             
                   checkFormAndSubmit();
             
              }
             
         }
   
    </script>

</head>
<body onLoad="javascript: document.frmLogin.txtUserID.focus();" background="image/whte5.gif">
<form id="frmLogin" name="frmLogin" method="post" action="check.asp">
 <table border="0" bordercolor="blue" cellspacing="0" cellpadding="5">
         
         <%
         
         if len(session("remark")) <> 0 then
         
              Response.Write "<tr><td colspan=""2"">" & session("remark") & "</td></tr>"
         
         end if
         
         %>
         
         <tr>
             <input type="text" name="hiddenField" value="<%=request.querystring("ref_num")%>">
              <td>user id:</td>
              <td><input type="text" size="20" maxlength="25" id="txtUserID" name="txtUserID" value="<%=session("userID")%>"></td>
         </tr>
         <tr><td colspan="2" height="15"></td></tr>
         <tr>
              <td>password:</td>
              <td><input type="password" size="20" maxlength="25" id="txtPassword" name="txtPassword" onKeyPress="javascript: checkForEnterKeyToSubmit();"></td>
         </tr>
         <tr>
     <td colspan="2" height="25">&nbsp; </td>
   </tr>
         <tr><td colspan="2" align="center"><input type="button" id="btnLogin" name="btnLogin" value=" login " class="button" onClick="javascript: checkFormAndSubmit();"></td></tr>
                   
    </table>

</form>

<%
session("remark") = ""
session("userID") = ""
session("password") = ""
%>

</body>
</html>
=========================

and when you authenticated the user you can get the value of the hidden field by

request.form("hiddenField")


check.asp
=========
<%@ Language="VBScript" %>

<!--#include file="Clssfd.asp"-->

<% response.buffer=true %>

<%

dim strUserId
dim strPassword
dim allowLogin

strUserId = Request.Form("txtUserID")
strPassword = Request.Form("txtPassword")
id = request.querystring("property")


Dim rsUsers
set rsUsers = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM customer WHERE login_ID = '" & strUserID & "' AND password = '" & strPassword & "';"
rsUsers.Open strSQL, objConn

If not rsUsers.EOF then        'User was found - check password
   If rsUsers("login_ID") = strUserID AND rsUsers("password") = strPassword then
       allowlogin=true

   else
    response.write request.form("hiddenField")
       response.write("Login Fail")
       allowuser=false
   end if
 

 %>

 <html>
 <head>
      <script language="JavaScript1.2">
     
           function forwardMainScreen() {
           
              window.opener.document.location = 'bid.asp?ref_num='+<%=request.form("hiddenField")%>;
                window.close();
               
           }
     
      </script>
       
      </head>
 <body onload="javascript: forwardMainScreen();">
 </body>
 

   <%

else
   
   session("remark") = "Please provide valid user ID and Password"
   Response.write ("Login Fail")

end if


%>

Now on your bid page you can again reference the value of the ref_num by using request.querystring

To check save this bid.asp

========
<%=request.querystring("ref_num")%>

==========

Now you can use this to search on your db for that specific record for the user to bid on..

HTH...

HAppy programming...

Commented:
sha_lini,

You can change the for loop with your do while loop of your recordset... and change value of the i variable with your unique key of the bid item.  for example rs("idnum")

Also you can any name of the hiddenfield just make that when you call

request.form("yourvariable")

HTH...

Happy programming...

Commented:
sha_lini,

Also you can use any name for the hiddenfield just make that when you call use.

HTH...

Happy programming...
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Author

Commented:
gladxml ,
Thank you very much .

it's working but i don't know how to change that i loop
i tryied like this but it showing undefined

    <td width="43">
     <% Do While Not objRst.EOF %>
 
     <div align="center"><img src="image/view.gif" width="30" height="15" onClick="javascript: showLoginScreen(<%=objRst(ref_num)%>);">
<%   objRst.MoveNext
 loop
  %>
      </div>

  </td>
</tr>
Commented:
sha_lini,

Assuming that you have a connection and a select statement
I think the problem is this part... The way you fetch the recordset field is incorrect..

<%=objRst(ref_num)%>

Try to use this instead

<%=objRst("ref_num")%>

I also made some testing here and I dont encounter any problem using the below script...

 you can use the script for checking...

Just to replace the database name(db3.mdb) & TAblename (sha)

======
<%
Dim oConn, dbPath
dbPath = Server.MapPath("db3.mdb")
Set oConn=Server.CreateObject("ADODB.Connection")
oConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & dbPath & ";"

dim rsUsers
dim sql

set objRst = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM sha;"
objRst.Open sql, oConn
%>


<script language="JavaScript1.2">
   
   function showLoginScreen(id_num) {
        var popup;

        wndLogin = window.open("popuplogin.asp?ref_num="+ id_num,"popup","resizable=yes, width=400, height=250");
    }
</script>

<td width="43">
    <% Do While Not objRst.EOF %>

    <div align="center"><img src="image/view.gif" width="30" height="15" onClick="javascript: showLoginScreen(<%=objRst("ref_num")%>);">
     </div>
<%   objRst.MoveNext
loop
 %>
 </td>

HTH...

Happy programming...

Commented:
sha_lini,

I will be out for the holiday I hope that the you already checked the code...

Anyway it will work just fine... The codes on my last is working perfectly here with me and tested it many times...

Good Luck on your project...

Merry Christmas & Happy New Year...

Happy programming...

Glad

Commented:
sha_lini,

Just paste this line of code in your original code and it will work just fine...  

<div align="center"><img src="image/view.gif" width="30" height="15" onClick="javascript: showLoginScreen(<%=objRst("ref_num")%>);">
    </div>

Happy programming...

Regards,
Glad

Author

Commented:
Glad ,

It's working perfactly. Thank you very much. I knew that you spend more time in this question and i realy appriaciate this help. You will get the point:)

<< Wish you merry chrismas and happy new year >>

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial