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

create pop up window at login page

Status
Not open for further replies.

antonyb

MIS
Aug 23, 2002
35
0
0
MY
Hi,

How could i trigger the pop up window when i was hit the submit button. The pop up window is without the IE toolbar and scrollbar and then this window will do all the staff here like display error message if key in wrong information and also if succesful login, it will go to next page.


<form name="login" method="post" action="demo/logonp.asp" target="_blank">
<br>
<font color="#000000" size="1" face="Arial"><strong>User ID :
</strong></font>
<input name="USERNAME" type="text" class="txtbox1" style="width:123" value="" maxlength="100">
<br>
<font size="2" face="Arial"><strong><font color="#000000" size="1">Password
:</font>
<input name="PASSWORD" type="password" class="txtbox1" style="width:123" value="" maxlength="100">
<font color="#000000" size="1"><br>
Port No :</font>
<input name="WebServerPortNumber" type="text" class="txtbox1" style="width:123" value="" maxlength="100">
<INPUT name=submit type=image
src="images/login.gif" alt=Go align="middle" width=51 height=18
border=0>
</strong></font>
</form>

Thx for advance

Rgds,
antony
 
Add an "onsubmit" to your form tag calling your javascript to pop the new window.

Code:
<form name="login" method="post" action="demo/logonp.asp" onsubmit="window.open(url,name,params)">

What it sounds like you really need is a form validation script though. I'd check out the javascript forum.

Good luck,


Wow JT that almost looked like you knew what you were doing!
 
Hi pixl8r,

Thanks for your method but how to link the javascript to trigger it to pop up?
Can you give more details.

Thx

Rgds,
antony
 
The method above will trigger when you click the submit button on the form.

The syntax of the onSubmit (as above) would be something like this:

Code:
onSubmit="window.open('demo/logonp.asp','','width=500,height=500,menubar=no scrollbars=no,toolbar=no,resizable=no');"

Personally I would just send the form to the validation script and then do an if/else on pass/fail. If you pass validation you continue otherwise popup and error window.

I hope that answers your question.

Wow JT that almost looked like you knew what you were doing!
 
It is possible this method can pass parameter to my asp page, i have problem here after i submit, it always jump to the error page it didn't go to my user page if login successful. How to avoid it continue go to the error page

Thx
 
I you might be able to simplify this a bit.

Simply post the form to your ASP page (logonp.asp).

on the ASP page:

Code:
<%
strUName = request.form("userName")
strPassword = request.form("password")

correctUN = "User"
correctPass = "UserPass"

if strUName = correctUN and strPassword = correctPass then
   response.redirect("nextpage.asp")
else
   response.write("User Name or password is incorrect please try again")
end if
%>

If you need help getting it to work the way you have it I'm going to need to see your code for the logonp page and the form.

By the way... the example above is not a very secure way to do this and is meant only as an example. I would recommend at least using a database of some sort to store User names and passwords.

Hope it helps.
 
Thanks, pixl8r. I still stuck at pop up window. Below is my form and login page

form.htm
<form name="form1" method="post" onSubmit="window.open('demo/logonp.asp','','width=500,height=500,menubar=no scrollbars=no,toolbar=no,resizable=no');"
>
<div align="center"><font color="#000000" size="1" face="Arial"><strong>User
ID :</strong></font><br>
<input name="USERNAME" type="text" class="txtbox1" style="width:100" value="" maxlength="100">
<br>
<font size="2" face="Arial"><strong><font color="#000000" size="1">Password
:</font></strong></font><br>
<font size="2" face="Arial"><strong>
<input name="PASSWORD" type="password" class="txtbox1" style="width:100" value="" maxlength="100">
<br>
<font color="#000000" size="1">Port No :</font><br>
<input name="WebServerPortNumber" type="text" class="txtbox1" style="width:50" value="80" maxlength="100" >
<br>
<INPUT name=submit2 type=image
src="images/login.gif" alt=Go align="top" width=51 height=18
border=0 onClick="self.location.reload();">
</strong></font> </div>

</form>

logonp.asp

<%

Response.Buffer = True
Dim strSQL, strHttp
Dim Logon
Dim DataConn
Dim DataCmd
Dim objRs


Session("DatabaseName") = Trim(Request("txtDatabaseName"))

Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.ConnectionTimeout = 30
DataConn.CommandTimeout = 15

'Select database
If Session("DatabaseName") = "Access" then
Session("strDataConn") = "DSN=accAutoPilot"
DataConn.Open Session("strDataConn")
Else
Session("strDataConn") = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=mobif-sa;Password=123456;Initial Catalog=mobif;Data Source=MOBIF-NEWWEB"
DataConn.Open Session("strDataConn")
End if
DataConn.CursorLocation = 3 'adUseClient

Set DataCmd = Server.CreateObject("ADODB.Command")
Set DataCmd.ActiveConnection = DataConn


'Select the different table if the database is different
If Session("DatabaseName") = "Access" then
strSQL = "SELECT * FROM USERS WHERE USERID ='" & Replace(Request.Form("USERNAME"),"'","''") & "' AND PASSWD = '" & Replace(Request.Form("PASSWORD"),"'","''") & "'"
Else
strSQL = "SELECT * FROM USER_SECURITY WHERE USERID ='" & Replace(Request.Form("USERNAME"),"'","''") & "' AND PWD_LEVEL1 = '" & Replace(Request.Form("PASSWORD"),"'","''") & "'"
End if

'Response.Write strSQL & "<BR>"

DataCmd.CommandText = strSQL

Set objRs = Server.CreateObject("ADODB.RecordSet")
Set objRs = DataCmd.Execute

'Response.Write objRs.EOF

If objRs.EOF = False Then
Logon = "PASS"

If Request.Form("USERNAME") = "spp" then

'Session("LoginUser") = Request.Form("USERNAME")
LoginUser = Request("USERNAME")
Session("PASSWORD") = Request.Form("PASSWORD")
Session("ErrorLogonEU") = ""
Session("ErrorChangePwd") = ""
Session("ErrorMisMatchPwd") = ""

Response.Redirect "Redirect2.asp?userid=" & LoginUser
Else
If Request.Form("USERNAME") = "cpm" then

'Session("LoginUser") = Request.Form("USERNAME")
LoginUser = Request("USERNAME")
Session("PASSWORD") = Request.Form("PASSWORD")
Session("ErrorLogonEU") = ""
Session("ErrorChangePwd") = ""
Session("ErrorMisMatchPwd") = ""

Response.Redirect "Redirect2.asp?userid=" & LoginUser
Else
If Request.Form("USERNAME") = "Quad42" then

'Session("LoginUser") = Request.Form("USERNAME")
LoginUser = Request("USERNAME")
Session("PASSWORD") = Request.Form("PASSWORD")
Session("ErrorLogonEU") = ""
Session("ErrorChangePwd") = ""
Session("ErrorMisMatchPwd") = ""

Response.Redirect "Redirect2.asp?userid=" & LoginUser
Else

If Request.Form("USERNAME") = "see" then

'Session("LoginUser") = Request.Form("USERNAME")
LoginUser = Request("USERNAME")
Session("PASSWORD") = Request.Form("PASSWORD")
Session("ErrorLogonEU") = ""
Session("ErrorChangePwd") = ""
Session("ErrorMisMatchPwd") = ""

Response.Redirect "Redirect2.asp?userid=" & LoginUser
Else

If Request.Form("USERNAME") = "komtar" then

'Session("LoginUser") = Request.Form("USERNAME")
LoginUser = Request("USERNAME")
Session("PASSWORD") = Request.Form("PASSWORD")
Session("ErrorLogonEU") = ""
Session("ErrorChangePwd") = ""
Session("ErrorMisMatchPwd") = ""

Response.Redirect "Redirect.asp?userid=" & LoginUser
Else

If Request.Form("USERNAME") = "gurney" then

'Session("LoginUser") = Request.Form("USERNAME")
LoginUser = Request("USERNAME")
Session("PASSWORD") = Request.Form("PASSWORD")
Session("ErrorLogonEU") = ""
Session("ErrorChangePwd") = ""
Session("ErrorMisMatchPwd") = ""

Response.Redirect "Redirect2.asp?userid=" & LoginUser
Else

If Request.Form("USERNAME") = "mobifkl" then

'Session("LoginUser") = Request.Form("USERNAME")
LoginUser = Request("USERNAME")
Session("PASSWORD") = Request.Form("PASSWORD")
Session("ErrorLogonEU") = ""
Session("ErrorChangePwd") = ""
Session("ErrorMisMatchPwd") = ""

Response.Redirect "Redirect2.asp?userid=" & LoginUser
Else

If Request.Form("USERNAME") = "clickers" then

'Session("LoginUser") = Request.Form("USERNAME")
LoginUser = Request("USERNAME")
Session("PASSWORD") = Request.Form("PASSWORD")
Session("ErrorLogonEU") = ""
Session("ErrorChangePwd") = ""
Session("ErrorMisMatchPwd") = ""

Response.Redirect "Redirect2.asp?userid=" & LoginUser
Else

If Request.Form("USERNAME") = "mobifsg" then

'Session("LoginUser") = Request.Form("USERNAME")
LoginUser = Request("USERNAME")
Session("PASSWORD") = Request.Form("PASSWORD")
Session("ErrorLogonEU") = ""
Session("ErrorChangePwd") = ""
Session("ErrorMisMatchPwd") = ""

Response.Redirect "Redirect2.asp?userid=" & LoginUser
Else

If Request.Form("USERNAME") = "esupport" then

'Session("LoginUser") = Request.Form("USERNAME")
LoginUser = Request("USERNAME")
Session("PASSWORD") = Request.Form("PASSWORD")
Session("ErrorLogonEU") = ""
Session("ErrorChangePwd") = ""
Session("ErrorMisMatchPwd") = ""

Response.Redirect "Redirect2.asp?userid=" & LoginUser
Else

'Session("LoginUser") = Request.Form("USERNAME")
LoginUser = Request("USERNAME")
Session("PASSWORD") = Request.Form("PASSWORD")
Session("ErrorLogonEU") = ""
Session("ErrorChangePwd") = ""
Session("ErrorMisMatchPwd") = ""
'Response.Redirect "Redirect.asp?userid=" & LoginUser

Response.Redirect "Redirect.asp?userid=" & LoginUser& "&ThePort=" &ServerPortNum 'Added by Charis 04122003

End If
End If
End If
End if
End if
End if
End if
End if
End if
End if
End If

If Logon = "" Then
Session("ErrorLogonEU") = "Invalid User ID or Password, please try again !!!"
Session("ErrorChangePwd") = ""
Session("ErrorMisMatchPwd") = ""

Response.Redirect("error.htm")



End if


objRs.close
DataConn.Close




%>

Rgds,
antony
 
OK the first problem I see is that you have replaced the form action with the onSubmit call. The form must have an action in this case it should be action="demo/logonp.asp"

Following is an extremely simplified revision of your asp page. I have not tested it as I don't have the correct databases but you will see that I was able to accomplish the same thing(and even a few new things) with approx 25% of the code. You may need to customize it a bit more to get it to work the way you want it to.

Code:
<%

Response.Buffer = True
Dim strSQL, strHttp
Dim Logon
Dim DataConn
Dim DataCmd
Dim objRs
Dim dbName,strUserName,strPassword

strUserName = Request.Form("USERNAME")
strPassword = Request.Form("PASSWORD")

dbName = Trim(Request("txtDatabaseName")) 'I don't see this in your form. 
Session("DatabaseName") = dbName

Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.ConnectionTimeout = 30
DataConn.CommandTimeout = 15


'select database
'make SELECT statment based on UserName only.
select case dbName
	case "Access"
		Session("strDataConn") = "DSN=accAutoPilot" 'not sure exactly why you are using session variables for this. Do you need to use it again on another page?
		DataConn.Open Session("strDataConn")
		strSQL = "SELECT * FROM USERS WHERE USERID ='" & Replace(strUserName,"'","''") & "'"
	case else
		Session("strDataConn") = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=mobif-sa;Password=123456;Initial Catalog=mobif;Data Source=MOBIF-NEWWEB"
		DataConn.Open Session("strDataConn")
		strSQL = "SELECT * FROM USER_SECURITY WHERE USERID ='" & Replace(strUserName,"'","''") & "'"
	end select
	
DataConn.CursorLocation = 3

set DataCmd = server.CreateObject("ADODB.Command")
set DataCmd.ActiveConnection = DataConn

DataCmd.CommandText = strSQL

set objRS = server.CreateObject("ADODB.RecordSet")
set objRS = DataCMD.Execute

'redirect if userName is invalid or if there is a problem
on Error Response.Redirect("error.htm")
'If objRs.EOF = False Then
'
'Check password and redirect if not correct

if objRs.Fields("PASSWORD") = strPassword then
	Session("logon") = true
else
	'redirect invalid user
	Response.redirect ("error.htm")
end if


'I combined all of your "UserNames" because the action of each one is the same.
if strUserName <> "" then
	LoginUser = strUserName
    Session("PASSWORD") = strPassword 'I'm not sure why you are storing the password in the session variable.
    Session("ErrorLogonEU") = ""
    Session("ErrorChangePwd") = ""
    Session("ErrorMisMatchPwd") = ""

    Response.Redirect "Redirect2.asp?userid=" & LoginUser
else
	LoginUser = Request("USERNAME")
    Session("PASSWORD") = Request.Form("PASSWORD")
    Session("ErrorLogonEU") = ""
    Session("ErrorChangePwd") = ""
    Session("ErrorMisMatchPwd") = ""
    'Response.Redirect "Redirect.asp?userid=" & LoginUser
    
    Response.Redirect "Redirect.asp?userid=" & LoginUser& "&ThePort=" &ServerPortNum 'Added by Charis 04122003
end if

objRs.close
DataConn.Close




%>

Then at the top of each "members only" page you would apply the following code:

Code:
<%
if (Not Session("Logon")) then
   response.redirect("form.htm")
end if
%>

On your form page you have a lot of different things trying to happen when you click submit. You should simplify this. For example:

Code:
<form name="form1" method="post" action="demo/logonp.asp">
          <div align="center"><font color="#000000" size="1" face="Arial"><strong>User ID :</strong></font><br>
            <input name="USERNAME" type="text" class="txtbox1" style="width:100" value="" maxlength="100">
            <br>
            <font size="2" face="Arial"><strong><font color="#000000" size="1">Password :</font></strong></font><br>
            <font size="2" face="Arial"><strong> 
            <input name="PASSWORD" type="password" class="txtbox1" style="width:100" value="" maxlength="100">
            <br>
            <font color="#000000" size="1">Port No :</font><br>
            <input name="WebServerPortNumber" type="text" class="txtbox1" style="width:50" value="80" maxlength="100" >
            <br>
            <INPUT name=submit2 type=image src="images/login.gif" alt=Go align="top" width=51 height=18 border=0>
            </strong></font> </div>
            </form>

The changes I made there completely remove the javascript pop up. I don't see where you need it.

Hope it helps!

Wow JT that almost looked like you knew what you were doing!
 
Sorry pixl8r, i forgot to tell you actually i really need a pop up window because my login page is using frame at the left hand side of the page. I need to show the mpeg streaming at pop window when they are successful login.
So without pop window it cannot fit my size of the mpeg streaming.

Thx,

Rgds,
antony
 
Open the new window from redirect2.asp. Maybe something like this:

Code:
<%
if (Not Session("Logon")) then
   response.redirect("form.htm")
end if
%>
<html>
<html>
<head>
<script language=javascript>

function popMovieWindow(){
   window.open('tstmovie.htm','Welcome','width=300, height=300,scrollbars=no,statusbar=no,toolbar=no,resizable=no');
}

window.onload = popMovieWindow;


</script>
<body>
Blah Blah
</body>
</html>

In other words redirect to the page that does the popup, rather than try to make the pop up a part of your log in process.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top