I’ve decided that I need to take a plunge into the exciting world of forms and flash, and thought this would be my first good project to do. I host my site on a system that has a custom login script that works wonderfully as is. I want to convert this over to a flash version to provide to the hsphere community that uses a similar login script. A great quick walkthrough of converting this to work with flash would be a real help.
<%
If Request.Form("submit") <> "" then
'------------------------------------------
' Enter your list of control panels in the
' following array
' Enter as many URL's as you require seperated by commas
'------------------------------------------
Dim arrControlPanelURL
arrControlPanelURL = Array("http://cp.3dmaxnet.com:8080")
'-------------------------------------
' setup other miscellaneous variables
'-------------------------------------
Dim strUserName, strUserPassword, strURL, strPostURL, i, bolLogin, strErrorMsg
strErrorMsg = ""
strUserName = trim(Request.Form("login"))
strUserPassword = trim(Request.Form("password"))
strPostURL = "/psoft/servlet/psoft.hsphere.CP?action=login&ftemplate=design/login.html"
'-------------------------------------------------------------
' Here comes the real work !
' For each control panel in the array try and log the user on
' check for error conditions etc, if successful then log
' the user into their contorl panel.
'-------------------------------------------------------------
Dim objXMLHTTP, strReturn
Set objXMLHTTP = SErver.CreateObject("Microsoft.XMLHTTP")
For i = 0 to ubound(arrControlPanelURL)
strURL = arrControlPanelURL(i) & strPostURL & "&login=" & strUserName & "&password=" & strUserPassword
objXMLHTTP.Open "POST", strURL , False
objXMLHTTP.Send
strReturn = objXMLHTTP.ResponseText
If instr(1, strReturn, "invalid password", 1) > 0 then ' Correct Password ?
strErrorMsg = "Incorrect password, please try again."
Exit For ' get the heck out of here
End If
If Instr(1, strReturn, "no such user", 1) = 0 then ' Find the User ?
bolLogin = True
strErrorMsg = ""
Exit For ' no point hanging around any longer
Else
bolLogin = False
strErrorMsg = "Username not found, please try again."
End if
Next
Set objXMLHTTP = Nothing
If bolLogin then
strReturn = Replace(strReturn, "/psoft/", arrControlPanelURL(i) & "/psoft/")
Dim intStart, intEnd, intLength
intStart = instr(1, strReturn, "URL=", 1)
intStart = intStart + 4
intEnd = instr(intStart, strReturn, """", 1)
intLength = intEnd - intStart - 1 ' remove extra char to cater for the trailing "/"
strURL = Mid(strReturn, intStart, intLength) & "?action=login&ftemplate=design/login.html&login=" & strUserName & "&password=" & strUserPassword
Response.Redirect strURL
End if
End if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Control Panel Login</title>
<style type="text/css">
table {border : 1px solid #000000;
background-color : #CCCCCC;}
td {font : 11px Verdana,arial,helvetica,sans-serif;}
.input {border : 1px Solid #000000;
color : #000000;
background : #EEEEEE;
font : 12px Verdana, Arial, Sans-Serif;}
.button {border-bottom : #404040 1px solid;
border-left : #999999 1px solid;
border-right : #404040 1px solid;
border-top : #999999 1px solid;
background : #EEEEEE;
color : #000000;
font : 11px tahoma,sans-serif;
height : 20px;
letter-spacing : 1px;}
</style>
</head>
<body bgcolor="#666666">
<form method="post" action="">
<table summary="" cellpadding="4" cellspacing="0" align="center">
<tr>
<td colspan="2" align="center" nowrap><strong>.:: CONTROL PANEL LOGIN ::.</strong></td>
</tr>
<tr>
<td colspan="2" align="center" nowrap><em><% = strErrorMsg %></em></td>
</tr>
<tr>
<td align="right"><strong>Login:</strong></td>
<td><input class="input" type="text" name="login" size="20"></td>
</tr>
<tr>
<td align="right"><strong>Password:</strong></td>
<td><input class="input" type="password" name="password" size="20"></td>
</tr>
<tr>
<td> </td>
<td>
<input class="button" type="submit" name="submit" value="Log In">
<input class="button" type="reset" name="reset" value="Clear Info">
</td>
</tr>
</table>
</form>
</body>
</html>