Gästbok

Skriv ett nytt inlägg

<% If request.querystring("New") = "true" then If IsReCaptchaOk() = true then If not request.form("name") = "" or not request.form("message") = "" then If not request.form("email") = "" and IsEmail(request.form("email")) = true then Dim connectstr connectstr="DRIVER={MySQL ODBC 5.1 Driver};SERVER=mysql525.loopia.se;UID=Jocke@t161226;PWD=1lathund1;DATABASE=terpsithea_se_db_2" Set oConn = Server.CreateObject("ADODB.Connection") oConn.Open connectstr 'registrera i sql bookings qry = "INSERT INTO Guestbook (INDATE, NAME, MESSAGE, EMAIL, ANSWER_TO_ID) VALUES ('" & Date() & "', '" & request.form("name") & "', '" & request.form("message") & "', '" & request.form("email") & "', '0')" Set oRS = oConn.Execute(qry) 'close the connection and recordset objects to free up resources 'oRS.close Set oRS=nothing oConn.Close Set oConn=nothing response.write("
Tack för ditt inlägg!
") If SendEmail("Hej, du har fått ett nytt inläg i gästboken på terpsithea.se

snabblänk", TPEMail, "Terpsithea.se", "Nytt inlägg i gästbok", "Terpsithea gästbok", "") = "ok" then End if else response.write("
E-postadressen (" & request.form("email") & ") som du fyllt i är inte en giltig e-postadress.
") End IF else response.write("
Något utav fälten som är obligatoriska är inte ifyllt
") End If else response.write("
Du måste kryssa i ReCaptcha 'jag är inte en robot'.
") End If else End If 'declare the variables Dim Connection Dim ConnString Dim Recordset Dim SQL 'define the connection string, specify database driver ConnString="DRIVER={MySQL ODBC 5.1 Driver};SERVER=mysql525.loopia.se;UID=Jocke@t161226;PWD=1lathund1;DATABASE=terpsithea_se_db_2" 'declare the SQL statement that will query the database SQL = "SELECT * FROM Guestbook ORDER BY INDATE DESC" 'create an instance of the ADO connection and recordset objects Set Connection = Server.CreateObject("ADODB.Connection") Set Recordset = Server.CreateObject("ADODB.Recordset") 'Open the connection to the database Connection.Open ConnString 'Open the recordset object executing the SQL statement and return records Recordset.Open SQL,Connection Do while not Recordset.EOF response.write("
") response.write("Datum: " & Recordset.Fields("INDATE") & "
") response.write("Namn: " & Recordset.Fields("NAME") & "
") 'response.write("E-post: " & Recordset.Fields("EMAIL") & "
") response.write("Meddelande:
" & replace(Recordset.Fields("MESSAGE"),vbcrlf,"
") & "
") recordset.MoveNext Loop 'close the connection and recordset objects to free up resources Recordset.Close Set Recordset=nothing Connection.Close Set Connection=nothing %>

" required>

">




* = obligatorisk