Forums

PHP

This topic is locked

convert asp to php (ADODB.Connection)

Posted 18 May 2011 08:02:16
1
has voted
18 May 2011 08:02:16 khairul anuar posted:
i need to convert this statement to php, i have no idea how to convert it since i am new

i hope i will get help soon

<%@ Language=VBScript %>

<%Response.Expires = -1 %>
<%Response.ExpiresAbsolute = Now() - 1 %>
<%Response.AddHeader "pragma", "no-cache" %>
<%Response.AddHeader "cache-control", "private" %>
<%Response.CacheControl = "no-cache" %>

<%
Response.Expires = -1000
Response.Buffer = True
Response.Clear
%>

<% Dim MyLogin

Set MyLogin = Server.CreateObject("ADODB.Connection"
ConnStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
ConnStr = ConnStr & "DBQ=" & Server.MapPath("db\users.mdb"
MyLogin.Open(ConnStr)

SQLtemp = "SELECT * FROM Users WHERE User = '" & Request.Form("loginname" & "' AND Password = '" & Request.Form("loginpass" & "'"
Set rs = MyLogin.Execute(SQLtemp)

If Request.Form("loginname" = "" AND Request.Form("loginpass" = "" Then
Session("Message" = ("<b><font face=""Verdana"" size=""2"" color=""#008080"">Login Failed! </font></b><font face=""Verdana"" size=""2"" color=""#0000FF"">Please enter your Username & Password.</font>"
Response.Redirect ("first.asp"
Response.End
End If

If Request.Form("loginname" = "" Then
Session("Message" = ("<b><font face=""Verdana"" size=""2"" color=""#008080"">Login Failed! </font></b><font face=""Verdana"" size=""2"" color=""#0000FF"">Please enter your Username.</font>"
Response.Redirect ("first.asp"
Response.End
End If

If Request.Form("loginpass" = "" Then
Session("Message" = ("<b><font face=""Verdana"" size=""2"" color=""#008080"">Login Failed! </font></b><font face=""Verdana"" size=""2"" color=""#0000FF"">Please enter your Password.</font>"
Response.Redirect ("first.asp"
Response.End
End If

If rs.eof then
rs.Close
MyLogin.Close
set MyLogin = Nothing
Session("Message" = ("<b><font face=""Verdana"" size=""2"" color=""#008080"">Login Failed! </font></b><font face=""Verdana"" size=""2"" color=""#0000FF"">Incorrect Username & Password.</font>"
Response.Redirect ("first.asp"
Response.End
End If

while not rs.eof

If Request.Form("loginname" = rs("User" AND Request.Form("loginpass" = rs("Password" Then

dim Your_LoginName
Your_LoginName = rs("User"
'dim Date_In
'Date_In = rs("Entry_Date"

Response.Cookies("LoginName" = Your_LoginName
'Response.Cookies("still" = Date_In

'Session.TimeOut = 20
Session("LoginName" = "Yes"

Response.Redirect "login.asp?UserLoggedIn=" & Your_LoginName
Else
Session("Message" = ("<font face=""Verdana"" size=""2"" color=""#FF0000"">Login Failed! </font><font face=""Verdana"" size=""2"" color=""#0000FF"">Incorrect Username & Password.</font>"
Response.Redirect ("first.asp"
Response.End
End If

rs.MoveNext
Wend

OnError Response.Redirect ("first.asp"


rs.Close
MyLogin.Close
set MyLogin = Nothing

%>

Reply to this topic