Language: asp (GeSHi-highlighted)rs(1) = Request.Form("UID")rs(2) = Request.Form("Password")rs(3) = Request.Form("DocType")rs(4) = Request.Form("DocNo")
Language: geshi (GeSHi-highlighted)<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html lang="en"><head><title>rodsdot.com :: generic database page - states table</title><meta name="author" content="Roderick Divilbiss"><meta name="copyright" content="© 2005 Roderick Divilbiss"></head><body><table id="statesTable" border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#000000"><% Dim rs, conn, command, connection, tableHTML command = "SELECT Code, Description FROM states ORDER BY Description;" Set conn = Server.CreateObject("ADODB.Connection") connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\inetpub\mysite\database\examples.mdb'" conn.open connection set rs = Server.CreateObject("ADODB.RecordSet") rs.open command, conn, 3, 1, 1 if NOT (rs.bof AND rs.eof) then while NOT rs.eof response.write "<tr><td>" & rs("Code") & "</td><td>" & rs("Description") & "</td></tr>" rs.movenext wend rs.close set rs = nothing end if conn.close set conn=nothing%></table></body></html>
Language: asp (GeSHi-highlighted)function saveComments(pName,pEmail,pPage,pPageSearch,pIP,pComments) Dim cmdText '* Add the new row openCommand Application("comments"),"saveComments 1" cmdText = "INSERT INTO comments (status, remoteAddress, sessionId, name, email, page, pageSearch, datePosted, comments) VALUES (@status, @remoteAddress, @sessionid, @name, @email, @page, @PageSearch, @datePosted, @comments)" addParam "@status",adInteger,adParamInput,CLng(4),0,"saveComments 2a" addParam "@remoteaddress",adVarChar,adParamInput,CLng(50),pIp,"saveComments 2b" addParam "@sessionid",adVarChar,adParamInput,CLng(50),Session.SessionID,"saveComments 2c" addParam "@name",adVarChar,adParamInput,CLng(50),pName,"saveComments 2d" addParam "@email",adVarChar,adParamInput,CLng(254),pEmail,"saveComments 2e" addParam "@page",adVarChar,adParamInput,CLng(254),pPage,"saveComments 2f" addParam "@pageSearch",adVarChar,adParamInput,CLng(254),pPageSearch,"saveComments 2f" addParam "@datePosted",adDate,adParamInput,CLng(now()),now(),"saveComments 2g" addParam "@comments",adLongVarWChar,adParamInput,CLng(Len(pComments)),pComments,"saveComments 2h" execCmd cmdText cmdText = "SELECT @@IDENTITY;" getRS db_rs, cmdText, "saveComments 3" saveComments = db_rs(0) '* clean up closeRS closeCommandend function
Language: geshi (GeSHi-highlighted)<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" --><%Option ExplicitSession.CodePage=28591Response.Charset="iso-8859-1"' no browser caching of this page !! to be used on all pagesResponse.Expires=-1Response.ExpiresAbsolute = Now() - 1' do not allow proxy servers to cache this page !! to be used on all pagesResponse.CacheControl="private"Response.CacheControl="no-cache"Response.CacheControl="no-store"%><!--#include virtual="/include/generalPurpose.asp"--><!--#include virtual="/include/thisPageClass.asp"--><!--#include virtual="/include/paramSQL.asp"--><%'*******************************************************************************' PAGE ROUTINES'*******************************************************************************function toNumber(x) Dim RegX Set RegX = NEW RegExp RegX.Pattern = "\D" RegX.Global = True x = RegX.Replace(x,"") IF x="" THEN toNumber = 0 ELSE toNumber=CInt(x)end functionfunction toDate(strDay,strMonth,strYear) Dim d, m, y d = toNumber(strDay) m = toNumber(strMonth) y = toNumber(strYear) toDate = DateSerial(y,m,d)end functionfunction writeDateSelect(pName,pMDY) Dim mdy, idx, lowIdx, maxIdx, out lowIdx=1 out = "<select name=""" & pName & """ size=""1"">" Select Case LCase(pMDY) Case "d" mdy = day(now()) maxIdx=31 Case "m" mdy = month(now()) maxIdx=12 Case "y" mdy = year(now()) lowIdx = mdy-1 maxIdx = mdy+7 End Select for idx = lowIdx to maxIdx if idx=mdy then out=out& "<option selected value=""" & idx & """>"& idx &"</option>" else out=out& "<option value=""" & idx & """>"& idx &"</option>" end if next writeDateSelect = out& "</select>" end functionfunction writeCustomersArray(pName) db_cmdText = "SELECT * from customer ORDER BY customerId;" ' open a command object on our database openCommand Application("keneso"), "writeCust 1" ' get our recordset using the open command object getRS db_rs, db_cmdText, "writeCust 2" Dim out, idx, item if NOT (db_rs.bof AND db_rs.eof) then out = "var "& pName &" = new Array();" & vbLF idx = 0 while NOT db_rs.eof out = out & " "& pName &"["& idx &"]=['" for each item in db_rs.fields out = out & item & "','" next ' backoff the trailing ,' and terminate the line with ]); out = Left(out, Len(out)-2) & "];" & vbLF ' increment our array index idx = idx + 1 db_rs.movenext wend writeCustomersArray = out & vbLF end if ' clean up closeRS closeCommandend functionfunction addDetailRecord(pUID, pPassword, pDocType, pDocNo, pDate, pIn, pOut, pPosition, pAddress) Dim cmdText '* Add the new row openCommand Application("keneso"),"addDetail 1" cmdText = "INSERT INTO log (customerid, key, docType, docNumber, position, address, date, in, out ) VALUES (@customerid, @key, @docType, @docNumber, @position, @address, @date, @in, @out)" addParam "@customerid",adVarChar,adParamInput,CLng(10),pUID,"addDetail 2a" addParam "@key",adVarChar,adParamInput,CLng(10),pPassword,"addDetail 2b" addParam "@docType",adVarChar,adParamInput,CLng(10),pDocType,"addDetail 2c" addParam "@docNumber",adVarChar,adParamInput,CLng(30),pDocNo,"addDetail 2d" addParam "@position",adVarChar,adParamInput,CLng(50),pPosition,"addDetail 2e" addParam "@address",adVarChar,adParamInput,CLng(100),pAddress,"addDetail 2f" addParam "@date",adDate,adParamInput,CLng(16),pDate,"addDetail 2g" addParam "@in",adVarChar,adParamInput,CLng(10),pIn,"addDetail 2h" addParam "@out",adVarChar,adParamInput,CLng(10),pOut,"addDetail 2i" execCmd cmdText '* clean up closeRS closeCommand addDetailRecord = "Record Added"end function'*******************************************************************************' FORM LOGIC'*******************************************************************************if thisPage.isPost then ' Day, Month, Year, Date, In are all reserved words in VBScript! ' Declare variables to hold posted fields Dim UID, Password, DocType, DocNo, tDate, tDay, tMonth, tYear, timein, timeout, position, address, posted ' Get the posted fields via our filter function UID = getField("UID,rXalpha") Password = getField("Password,rXsafe") DocType = getField("DocType,rXsafe") DocNo = getField("DocNo,rXsafe") tDay = getField("InD,rXint") tMonth = getField("InM,rXint") tYear = getField("InY,rXint") tDate = toDate(tDay, tMonth, tYear) timein = getField("in,rXsafe") timeout = getField("out,rXsafe") position = getField("position,rXsafe") address = getField("address,rXaddress") ' A message string to communicate results Dim Message Message="" ' check for required fields here if (UID="") then Message = "The UID is required." end if ' check more if you want if Message="" then ' Message = addDetailRecord(UID, Password, DocType, DocNo, tDate, timein, timeout, position, address) Message = "UID, "&UID&"<br>Password, "&Password&"<br>DocType, "&DocType&"<br>DocNo, "&DocNo&"<br>tDate, "&tDate&"<br>tDay, "&tDay&"<br>tMonth, "&tMonth&"<br>tYear, "&tYear&"<br>timein, "&timein&"<br>timeout, "&timeout&"<br>position, "&position&"<br>address"&address&"<br>" & vbLF end if else Message = " " end if%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="content-type" content="text/html;charset=iso-8859-1"><meta name="author" content="Farzin"><title>::::CLIENTI::::</title><link href="main.css" rel="styleSheet" type="text/css"><script type="text/javascript"><!--<%=writeCustomersArray("customers")%>var currentIdx='';function createCustomerSelect() { var tmpHTML = '<select id="myOptions" name="myOptions"'; tmpHTML += ' onchange="fillFormFields(this.selectedIndex);">'; tmpHTML = tmpHTML + ' <option>Select...</option>\n'; for (var idx=0; idx<customers.length; idx++) { tmpHTML = tmpHTML + ' <option>' + customers[idx][0] + '</option>\n'; } tmpHTML = tmpHTML + '</select>'; return tmpHTML;}function fillFormFields(idx) { if ((idx!=0)&&(idx!=currentIdx)) { if (currentIdx!='') { var cnfrm = confirm('Do you want to replace the form information\nfor '+document.getElementById('UID').value+' with\nthe information for '+customers[idx-1][0]+'?'); } if ((currentIdx=='')||(cnfrm)) { document.getElementById('UID').value=customers[idx-1][0]; document.getElementById('Password').value=customers[idx-1][1]; document.getElementById('DocType').value=customers[idx-1][2]; document.getElementById('DocNo').value=customers[idx-1][3]; document.getElementById('address').value=customers[idx-1][4]; //document.getElementById('postalCode').value=customers[idx][5]; //document.getElementById('phoneNumber').value=customers[idx][6]; currentIdx=idx; } } }//--></script></head><body><p><%=Message%></p><center><div class="main"> <table border="1" style="border-collapse:collapse; background-color:#EEE" cellpadding="3" width="700" height="32"> <tr> <td><div class="titolo">Aggiungi nuovo utente - Add Customer</div></td> <td style="text-align:right"><span class="link"><a href="datiutenti.asp">dati utenti - customer data</a></span></td> </tr> <tr> <td><script language="javascript" type="text/javascript">document.write(createCustomerSelect());</script></td> <td style="text-align:right"> </td> </tr> </table> <br> <hr> <br> <form action="default.asp" method="post"> <table border="1" style="border-collapse:collapse; background-color:#EEE" cellpadding="3" width="700"> <tr> <td><span class="testo">Cognome-UID </span></td> <td><input id="UID" name="UID" type="text" size="30"></td> <td><span class="testo">Nome-Pass </span></td> <td><input id="Password" name="Password" type="text" size="30" ></td> </tr> <tr> <td><span class="testo">Tipo documento </span></td> <td><input id="DocType" name="DocType" type="text" size="10"></td> <td><span class="testo">N° documento </span></td> <td><input id="DocNo" name="DocNo" type="text" size="30"></td> </tr> <tr> <td><span class="testo">Data-Date </span></td> <td colspan="3"><%=writeDateSelect("InD","d")%> / <%=writeDateSelect("InM","m")%> / <%=writeDateSelect("InY","y")%></td> </tr> <tr> <td><span class="testo">In </span></td> <td colspan="3"><input id="in" name="in" type="text" size="24"></td> </tr> <tr> <td><span class="testo">Out </span></td> <td colspan="3"><input id="out" name="out" type="text" size="24"></td> </tr> <tr> <td><span class="testo">Postazione </span></td> <td colspan="3"><input id="position" name="position" type="text" size="24"> Postal Zone?</td> </tr> <tr> <td><span class="testo">Indirizzo </span></td> <td colspan="3"><input id="address" name="address" type="text" size="70"></td> </tr> <tr> <td style="text-align:center" colspan="4"><input type="submit" name="submit" value="Add"></td> </tr> </table> </form></div></center></body></html>
Language: asp (GeSHi-highlighted)fuction customerExists(pUID) db_cmdText = "SELECT customerId from customer WHERE (customerId="& pUID &");" ' open a command object on our database openCommand Application("keneso"), "customerExists 1" ' get our recordset using the open command object getRS db_rs, db_cmdText, "customerExists 2" Dim out, idx, item if NOT (db_rs.bof AND db_rs.eof) then customerExists=true else customerExists=false end if ' clean up closeRS closeCommandend function function addCustomer(pUID, pPassword, pDocType, pDocNo, pAddress) Dim cmdText '* Add the new row openCommand Application("keneso"),"addCustomer 1" cmdText = "INSERT INTO customer (customerid, key, docType, docNumber, address ) VALUES (@customerid, @key, @docType, @docNumber, @address)" addParam "@customerid",adVarChar,adParamInput,CLng(10),pUID,"addCustomer 2a" addParam "@key",adVarChar,adParamInput,CLng(10),pPassword,"addCustomer 2b" addParam "@docType",adVarChar,adParamInput,CLng(10),pDocType,"addCustomer 2c" addParam "@docNumber",adVarChar,adParamInput,CLng(30),pDocNo,"addCustomer 2d" addParam "@address",adVarChar,adParamInput,CLng(100),pAddress,"addCustomer 2e" execCmd cmdText '* clean up closeRS closeCommandend function
Language: asp (GeSHi-highlighted)if Message="" then if customerExists(UID) then Message = addDetailRecord(UID, Password, DocType, DocNo, tDate, timein, timeout, position, address) else addCustomer(UID, Password, DocType, DocNo, address) Message = addDetailRecord(UID, Password, DocType, DocNo, tDate, timein, timeout, position, address) end if end if