Avatar billede bassa Nybegynder
05. marts 2009 - 09:35

Søger hjælp til CAPTCHA ASP/CSS script funktion!

Hej!

Jeg har fundet en fin lille CAPTCHA løsning til min web-formular, men jeg er en total spade til programmering (specielt ASP), så jeg håbede på, at nogle kloge hoveder herinde kunne hjælpe mig lidt.

Jeg har 3 filer på min server:

captcha.asp
mail.asp
skriv.asp

Skriv.asp indeholder min Form, og med POST henviser den til mail.asp. Mail.asp indeholder en enkel metode til at sætte Form informationerne op i et pænt layout til modtageren af henvendelsen (brugere som udfylder formularen, og videresender dem til webmaster).

Captcha.asp indeholder naturligvis metoden til at opsætte og afvikle CAPTCHA-delen når Form afsendes til webmaster.

Mail.asp og captcha.asp er integreret i hinanden (samme script), da der udføres 2 opgaver når Form afsendes; Captcha-delen samt opsætning af e-mail layout til modtager (webmaster).

Mit problemet er, at den ikke afsender noget. Jeg har leget rundt med det i noget tid nu, men kan stadig ikke få den til at makke ret. :(

Her er koden til selve Form-siden skriv.asp:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Frøsø Køkkenfornyelse tilbyder salg og montage af køkkenelementer som f.eks. låger, bordplader, skuffer og vaske. Kvalitet, service og fornuftige priser er nøgleord for vores virksomhed." />
<meta name="keywords" content="frøsø, froso, køkkenfornyelse, køkken, køkkenlåger, køkkenlåge, låger, låge, bordplader, bordplade, skuffe, skuffer, køkkenfront, køkkenfronte, køkkenfronter, køkkenvask, køkkenvaske, vaske, hængsler, kvalitet, service, priser" />
<meta name="author" content="Ulrik Foldager" />
<title>Fr&oslash;s&oslash; K&oslash;kkenfornyelse - Forside</title>

<link href="../css/froso.css" rel="stylesheet" type="text/css" media="screen" />
<link href="../css/print.css" rel="stylesheet" type="text/css" media="print" />
<link href="../css/lightbox.css" rel="stylesheet" type="text/css" media="screen" />
<link href="../facefiles/facebox.css" rel="stylesheet" type="text/css" media="screen" />

<script type="text/javascript" src="../js/textsizer.js"></script>

<script src="../facefiles/jquery-1.2.2.pack.js" type="text/javascript"></script>
<script src="../facefiles/facebox.js" type="text/javascript"></script>

<script type="text/javascript" src="../js/prototype.js"></script>
<script type="text/javascript" src="../js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="../js/lightbox.js"></script>

<script type="text/javascript">
    jQuery(document).ready(function($) {
      $('a[rel*=facebox]').facebox()
    })
</script>

<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

</head>

<body onload="MM_preloadImages('../images/button_share_on.gif')">

<script type="text/javascript">
addthis_pub            = 'bassa';
addthis_logo            = 'http://www.froso.dk/test/images/logo.gif';
addthis_logo_background = 'EFEFFF';
addthis_logo_color      = 'B41414';
addthis_brand          = 'Frøsø Køkkenfornyelse';
addthis_options        = 'favorites, facebook, myspace, live, google, more';
</script>

<script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>

<!-- Top Body Start -->
<div id="topbg"><div id="main">

<!-- Main Header Start -->
<div id="header">
<div id="logo"><a href="#"><img src="../images/logo.gif" alt="IMAGE" width="211" height="100" border="0" /></a></div>
<a href="kontakt.html" title="Kontakt Frøsø Køkkenfornyelse" target="_self" class="contact_on">Kontakt</a>
<a href="../omfroso/omfroso.html" title="Læs mere om Frøsø Køkkenfornyelse" target="_self" class="about_off">Om Fr&oslash;s&oslash;</a>
<a href="../galleri/galleri.html" title="Se vores galleri" target="_self" class="gallery_off">Galleri</a>
<a href="../produkter/produkter.html" title="Se vores produkter" target="_self" class="products_off">Produkter</a>
<a href="../index.html" title="Gå til forsiden" target="_self" class="frontpage_off">Forside</a></div>
<!-- Main Header End -->

<!-- Image Start -->
<div id="image"><img src="../images/header_skriv.jpg" alt="IMAGE" width="960" height="240" border="0" /></div>
<!-- Image End -->

</div></div>
<!-- Top Body End -->

<!-- Breadcrumb Start -->
<div id="breadcrumb">
<a title="Del og gem til dine favoritter" href="http://www.addthis.com/bookmark.php" class="share" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]'), MM_swapImage('Share','','../images/button_share_on.gif',1)" onmouseout="addthis_close(), MM_swapImgRestore()" onclick="return addthis_sendto()"> <img src="../images/button_share_off.gif" name="Share" width="78" height="22" hspace="10" vspace="3" border="0" id="Share" alt="Del og gem til dine favoritter"/></a>
<a title="Print denne side" href="java script:window.print()" class="print"></a>
<a title="Send et link til en ven" href="#" class="send"></a>
<a title="Gør teksten mindre" href="java script:ts('textarea',-1);ts('footer',0)" class="decrease"></a>
<a title="Gør teksten større" href="java script:ts('textarea',1);ts('footer',0)" class="increase"></a></div>
<!-- Breadcrumb End -->

<!-- Main Content Start -->
<div id="maincontent">

<!-- Sub-Menu Start -->
<div id="submenu">
<a href="adresse.html" title="Adresse" target="_self" class="adresse">Adresse</a></p>
<a href="skriv.asp" title="Skriv til os" target="_self" class="skriv">Skriv til os</a>
<a href="daekning.html" title="Her kører vores sælgere" target="_self" class="daekning">Dækningsområde</a></div>
<!-- Sub-Menu End -->

<!-- Content Start -->
<div id="content">
    <div class="h1">Velkommen til Fr&oslash;s&oslash; K&oslash;kkenfornyelse</div>
    <div id="textarea" class="text">
      Udfyld venligst nedenstående formular, så vender vi tilbage til Dem snarest muligt.
      <p>Felter med en asteriks (*) bedes udfyldt.</p>
      <form action="mail.asp" method="post" name="FormMail" target="_self" id="FormMail"><fieldset class="login">
        <legend>Kontakt oplysninger</legend>
            <div>
                <label for="navn">*Navn:</label>
                <input name="navn" type="text" id="navn" size="30" maxlength="40">
            </div>
            <div>
                <label for="adresse">*Adresse:</label>
                <input name="adresse" type="text" id="adresse" size="30" maxlength="40">
            </div>
        <div>
            <label for="postnr">*Post nr.:</label>
                <input name="postnr" type="text" id="postnr" size="30" maxlength="40">
        </div>
            <div>
              <label for="by">*By:</label>
                <input name="by" type="text" id="by" size="30" maxlength="40">
            </div>
        <div>
          <label for="telefon">*Telefon:</label>
                <input name="telefon" type="text" id="telefon" size="30" maxlength="40">
        </div>
            <div>
              <label for="e-mail">E-mail:</label>
                <input name="e-mail" type="text" id="e-mail" size="30" maxlength="40">
        </div>
            <div>
              <label for="kommentar">*Kommentar:</label>
                <textarea name="kommentar" cols="40" rows="6" wrap="physical" id="kommentar"></textarea>
            </div>
            <p>
            <!--#include virtual="/test/kontakt/captcha.asp"-->
            <%Response.Write CreateCAPTCHA%>
                <input type="text" name="CaptchaBox" />
            </p>
        <button type="submit" class="submit" title="Send oplysningerne" id="submitall"></button>
        <button type="reset" class="clearall" title="Slet alle oplysninger" id="clearall"></button>
        </fieldset>
    </form>


   



</div></div>
<!-- Content End -->

</div>
<!-- Main Content End -->

<!-- Footer Start -->
<div id="footer">
      Frøsø Køkkenfornyelse &middot; Oldenvej 7 &middot; 3490 Kvistgård<br/>
  Tlf.: 4917 7728 &middot; Fax: 4917 7738 &middot; E-mail: <a href="../frank@froso.dk" class="footerlink">info@froso.dk</a></div>
<!-- Footer End -->

</body>
</html>


Ovenstående kode er fin nok, og virker efter hensigten. Jeg tror, at problemet ligger et sted i selve mail/captcha scriptet som kommer hér:

<%
Dim sSubject
Dim sBody, sBodyHtml

Dim referers
referers = Array("www.froso.dk")

validReferer = false
    referer = Request.ServerVariables("HTTP_REFERER")
    referer = Mid(referer, len("http://") + 1)
    i = InStr(referer, "/")
    if i > 1 then
      referer = Mid(referer, 1, InStr(referer, "/") - 1)
      referer = Mid(referer, InStr(referer, ".") + 1)
      for each domain in referers
        if domain = referer then
          validReferer = true
        end if
      next
    end if
    if not validReferer then
      //display error to users here
    end if

sBodyHtml = sBodyHtml & "<font size=""2"" face=""Verdana"">Dato: " & Now & "</font><br>"

sBodyHtml = sBodyHtml & "<font size=""2"" face=""Verdana""><strong>Kunde oplysninger:</strong><br>"
sBodyHtml = sBodyHtml & "Navn: " & Chr(9) & Request.Form("Navn") & "<br>"
sBodyHtml = sBodyHtml & "Adresse: " & Chr(9) & Chr(9) & Request.Form("Adresse") & "<br>"
sBodyHtml = sBodyHtml & "Post nr.: " & Chr(9) & Chr(9) & Request.Form("Postnr") & "<br>"
sBodyHtml = sBodyHtml & "By: " & Chr(9) & Chr(9) & Chr(9) & Request.Form("By") & "<br>"
sBodyHtml = sBodyHtml & "Telefon: " & Chr(9) & Request.Form("Telefon") & "<br>"
sBodyHtml = sBodyHtml & "E-mail: " & Chr(9) & Chr(9) & Request.Form("E-mail") & "<br>"
sBodyHtml = sBodyHtml & "Kommentar: " & Chr(9) & Chr(9) & Request.Form("Kommentar") & "<br>" & "<br></font>"

'Overfører header til mail
sBodyMail = sBodyHtml

'Mail til Frøsø Køkkenfornyelse ApS
Set JMail = Server.CreateObject("JMail.SMTPMail")

JMail.ServerAddress = "smtp.servnet.dk"

JMail.Sender = "postmaster@froso.dk"
jmail.SenderName = "www.froso.dk"
JMail.Subject = "Kundehenvendelse"
jmail.HTMLBody = "<html><body>" & sBodyMail

JMail.AddRecipient "info@ufodesign.dk"

JMail.Body = "Test" & VbCrLf & VbCrLf
JMail.Body = JMail.Body & "Med venlig hilsen"

' 1 - highest priority (Urgent)
' 3 - normal
' 5 - lowest
JMail.Priority = 1

'//removed some code here

Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

'// YOUR PREFERENCES
Const MAX_NUMBER_OF_CHARACTERS = 3    '// How many characters in our CAPTCHA?
Const MAX_LENGTH_CSS_CLASSES = 12      '// How many characters in the CSS class names?
Const CAPTCHA_CHARACTER_FACTOR = 40  '// How many pixels are we moving each new character from left?
Const CAPTCHA_BOX_BORDER = "border: 2px solid #ccc;"  '// Style the div box holding the CAPTCHA.
Const CAPTCHA_BOX_WIDTH = 160              '// Width. This value should balance the number of characters and size.
Const CAPTCHA_BOX_HEIGHT = 80              '// Same as above.
Const NAME_OF_CAPTCHA_TEXTBOX = "CaptchaBox"    '// Name of CAPTCHA text box. Rename this!!


Dim m_arrCaptcha()            '// Array holding our CAPTCHA charaters. Hold in session variable.
Dim m_arrCaptchaScreen()  '// Parallell array where some items migth be hex/decimal encoded for display on screen.
Dim m_sCSS                        '// Our CSS
Dim m_sJavascript                '// Our Javascript
Dim m_sUserResult              '// Return a response to client/demo if success or failure

Dim m_sNameOfWrapperDiv  '// Holding the id name attribute for the div wrapping the CAPTCHA?
Dim m_arrColor(4)              '// Array of colors for the characters
Dim m_arrColorNew(4)        '// Same colors randomized
Dim m_arrFontFamily(4)        '// Array of font family strings
Dim m_arrFontFamilyNew(4)  '// Same fonts randomized
Dim m_arrFontSize(4)          '// Array of font sizes
Dim m_arrFontSizeNew(4)    '// Same font sizes now randomized
Dim m_arrTopPosition(4)      '// Array of top position values
Dim m_arrTopPositionNew(4) '// Same values randomized
Dim m_arrClassNames()        '// Array of names for the CSS classes
Dim m_arrQuestions(0)          '// Array of questions for the human visitor
Dim m_lngQuestionIndex      '// This number between 0 - 3 defines what question to ask the human visitor
Dim m_arrCaptchaColor(2)    '// Array holding the color of the character we are asking the visitor for
Dim m_arrCSSStrings(4)        '// Array holding our CSS elements/strings
Dim m_arrCSSStringsNew(4)  '// Same strings now randomly and uniquely sorted

'// START UP THE MODULE ARRAYS
m_arrColor(0) = "green"
m_arrColor(1) = "blue"
m_arrColor(2) = "red"
m_arrColor(3) = "black"
m_arrColor(4) = "yellow"

m_arrFontFamily(0) = "Verdana"
m_arrFontFamily(1) = "Arial"
m_arrFontFamily(2) = "Tahoma"
m_arrFontFamily(3) = "Courier"
m_arrFontFamily(4) = "Georgia"

m_arrFontSize(0) = 24
m_arrFontSize(1) = 50
m_arrFontSize(2) = 60
m_arrFontSize(3) = 40
m_arrFontSize(4) = 70

m_arrTopPosition(0) = 5
m_arrTopPosition(1) = 10
m_arrTopPosition(2) = 15
m_arrTopPosition(3) = 5
m_arrTopPosition(4) = 10

m_arrQuestions(0) = "Before submitting this form, please type the characters displayed above:"

m_arrCSSStrings(0) = "position: absolute;"
m_arrCSSStrings(1) = "top: "
m_arrCSSStrings(2) = "left: "
m_arrCSSStrings(3) = "color: "
m_arrCSSStrings(4) = "font: bold "


'------------------------------------------------------------------------------------------------------------
' Comment: Call this function from where you want to include the CAPTCHA.
'------------------------------------------------------------------------------------------------------------
Function CreateCAPTCHA()
    On Error Resume Next

    Dim i, iTmp, sTmp

'---------------------------- Create our CAPTCHA!

    '// This holds plain text characters. They are stored in a session variable and compared with the user input.
    ReDim m_arrCaptcha(MAX_NUMBER_OF_CHARACTERS - 1)
    '// This holds the decimal and hexified characters displayed on screen.
    ReDim m_arrCaptchaScreen(MAX_NUMBER_OF_CHARACTERS - 1)

    For i = 0 To (MAX_NUMBER_OF_CHARACTERS - 1)

        sTmp = UCase(RandomString(1))
        iTmp = RandomNumber(101)

        m_arrCaptcha(i) = sTmp
       
        If iTmp < 33 Then m_arrCaptchaScreen(i) = "&#" & Asc(UCase(sTmp)) & ";"              '// Decimal
        If iTmp > 66 Then m_arrCaptchaScreen(i) = "&#x" & Hex(Asc(UCase(sTmp))) & ";"    '// Hexify
        If iTmp < 67 And iTmp > 32 Then m_arrCaptchaScreen(i) = UCase(sTmp)                  '// Plain Ascii

    Next

'---------------------------- What question will we ask the human visitor?

    m_lngQuestionIndex = 0 '//always use first question

'---------------------------- Create CSS and javascript

    Call CreateStyleSheet
    Call CreateJavascript

'---------------------------- Check to see if someone submitted CAPTCHA, machine or human
'// You may want to move this code to another part of your own application and do the testing there.

    If Len(Request.Form(NAME_OF_CAPTCHA_TEXTBOX)) > 0 Then

        If UCase(Request.Form(NAME_OF_CAPTCHA_TEXTBOX)) = UCase(Session("CAPTCHA")) Then
            Response.Write("you typed correct code")
            Else
            Response.Write("you typed wrong code")
        End If

    End If
   
    '// Nothing was submitted, so just set a new session value which is our CAPTCHA characters or a color
    Session("CAPTCHA") = Replace(Join(m_arrCaptcha), " ", "")

    '// We will ask visitor for a color! Reduce m_lngQuestionIndex by 1 to match the m_arrCaptchaColor array
    If (m_lngQuestionIndex > 0) Then Session("CAPTCHA") = m_arrCaptchaColor(m_lngQuestionIndex - 1)

'---------------------------- Return the html

    CreateCAPTCHA = m_sCSS & m_sJavascript

End Function

'------------------------------------------------------------------------------------------------------------
' Comment: Randomize our module arrays holding the CSS values.
'------------------------------------------------------------------------------------------------------------
Sub InitArrays()
    On Error Resume Next
   
    '// First 4 arrays are randomly sorted meaning that all characters might have the same color.
    Call RandomizeArray(m_arrColor, m_arrColorNew)
    Call RandomizeArray(m_arrFontFamily, m_arrFontFamilyNew)
    Call RandomizeArray(m_arrFontSize, m_arrFontSizeNew)
    Call RandomizeArray(m_arrTopPosition, m_arrTopPositionNew)
    Call RandomizeArrayUnique(m_arrCSSStrings, m_arrCSSStringsNew)
   
End Sub

'------------------------------------------------------------------------------------------------------------
' Comment: Build the CSS.
'------------------------------------------------------------------------------------------------------------
Sub CreateStyleSheet()
    On Error Resume Next
   
    Dim sCSS, i, l, iLeft, sTmp, sTmpClassName
 
'---------------------------- Create the CSS for the div box

    '// First create a random name for the wrapper div.
    m_sNameOfWrapperDiv = RandomString(MAX_LENGTH_CSS_CLASSES)
   
    sCSS = "<style type=""text/css"">" & vbCrLf
    sCSS = sCSS & "#" & m_sNameOfWrapperDiv & " {" & vbCrLf
    sCSS = sCSS & CAPTCHA_BOX_BORDER & vbCrLf
    sCSS = sCSS & "position: relative;" & vbCrLf
    sCSS = sCSS & "width: " & CAPTCHA_BOX_WIDTH & "px;" & vbCrLf
    sCSS = sCSS & "height: " & CAPTCHA_BOX_HEIGHT & "px;" & vbCrLf
    sCSS = sCSS & "}" & vbCrLf

    '// Array holding the class names we will produce in the next loop
    ReDim m_arrClassNames(MAX_NUMBER_OF_CHARACTERS - 1)

    '// Remember the characters left position. Increase this value in every loop.
    iLeft = 10
   
'---------------------------- Build the CSS for our CAPTCHA

    For i = 0 To (MAX_NUMBER_OF_CHARACTERS - 1)

        '// Initialize our module arrays. We are randomizing them every time we get here.
        Call InitArrays
       
        sTmpClassName = RandomString(MAX_LENGTH_CSS_CLASSES)
        sCSS = sCSS & "." & sTmpClassName & " {" & vbCrLf

'---------------------------- Loop the 5 CSS strings and fill them with values
        For l = 0 To 4
            sTmp = m_arrCSSStringsNew(l)

            If InStr(sTmp, "color") > 0 Then
                sTmp = sTmp & m_arrColorNew(l) & ";" & vbCrLf

                '// We need to remember the colors when asking the visitors to type them so put them in an array.
                If Not i > UBound(m_arrCaptchaColor) Then m_arrCaptchaColor(i) = m_arrColorNew(l)
            End If

            If InStr(sTmp, "font") > 0 Then sTmp = sTmp & m_arrFontSizeNew(l) & "px " & _
                            m_arrFontFamilyNew(l) & ";" & vbCrLf
            If InStr(sTmp, "top") > 0 Then sTmp = sTmp & m_arrTopPositionNew(l) & "px;" & vbCrLf
            If InStr(sTmp, "left") > 0 Then sTmp = sTmp & iLeft & "px;" & vbCrLf
            If InStr(sTmp, "position") > 0 Then sTmp = sTmp & vbCrLf
                       
            sCSS = sCSS & sTmp
        Next
       
        '// Store the CSS class names in array
        m_arrClassNames(i) = sTmpClassName
        '// Calculate the new left position for next CAPTCHA character
        iLeft = (iLeft + CAPTCHA_CHARACTER_FACTOR)
        sCSS = sCSS & "}" & vbCrLf

    Next

    m_sCSS = sCSS & "</style>"

End Sub

'------------------------------------------------------------------------------------------------------------
' Comment: Create the javascript with our unique css class names and the CAPTCHA characters.
'------------------------------------------------------------------------------------------------------------
Sub CreateJavascript()
    On Error Resume Next

    Dim i, sJScript

    sJScript = "<script type=""text/javascript"">" & vbCrLf
    sJScript = sJScript & "document.write('<div id=""" & m_sNameOfWrapperDiv & """>');" & vbCrLf

    For i = 0 To (MAX_NUMBER_OF_CHARACTERS - 1)
        sJScript = sJScript & "document.write('<span class=""" & m_arrClassNames(i) & """>" & _
                        m_arrCaptchaScreen(i) & "</span>');" & vbCrLf
    Next

    sJScript = sJScript & "document.write('</div>');" & vbCrLf
    sJScript = sJScript & "</script>" & vbCrLf

    sJScript = sJScript & "<p><b>" & m_arrQuestions(m_lngQuestionIndex) & "</b></p>" & vbCrLf

    m_sJavascript = sJScript

End Sub

'------------------------------------------------------------------------------------------------------------
' Comment: Randomize array but make sure all values are present in the new array.
'------------------------------------------------------------------------------------------------------------
Function RandomizeArrayUnique(arr, arrNew)
    On Error Resume Next

    Dim i, l, sBuf, sTmp, iMax

    iMax = UBound(arr)

    ReDim arrNew(iMax)

    For i = 0 To iMax

        '// This should be enough looping
        For l = 1 To (iMax * 20)
            sTmp = arr(RandomNumber(iMax + 1))

            If InStr(sBuf, sTmp) = 0 Then
                sBuf = (sBuf & sTmp)
                arrNew(i) = sTmp
                Exit For
            End If

        Next
    Next

End Function

'------------------------------------------------------------------------------------------------------------
' Comment: Randomize our module arrays holding the CSS. One value might appear several times.
'------------------------------------------------------------------------------------------------------------
Function RandomizeArray(arr, arrNew)
    On Error Resume Next

    Dim i

    ReDim arrNew(UBound(arr))

    For i = LBound(arr) To UBound(arr)
        arrNew(i) = arr(RandomNumber(UBound(arr) + 1))
    Next

End Function

'------------------------------------------------------------------------------------------------------------
' Comment: Return a random number not bigger than the input parameter.
'------------------------------------------------------------------------------------------------------------
Function RandomNumber(iMax)
    On Error Resume Next

    Randomize
    RandomNumber = Int(iMax * Rnd)

End Function

'------------------------------------------------------------------------------------------------------------
' Comment: Create a random string of lower case letters [a-z] for the css class names.
'------------------------------------------------------------------------------------------------------------
Function RandomString(iMax)
    On Error Resume Next

    Dim i, sTmp

    For i = 1 To iMax
        sTmp = sTmp & Chr(97 + RandomNumber(26))    '// Return a random number between 97 and 122, ascii values for [a-z]
    Next

    RandomString = sTmp

End Function

'============================================================ END OF ASP CODE
%>


Mail-delen af ovenstående .asp script som ender ved '//removed some code here virker fint, og jeg har brugt den med stor success.

En anden gut har prøvet at interegrere de to scripts i samme script, men den sender ikke informationer afsted, desværre.

Jeg antager, at det skyldes et problem med captcha-delen?

Jeg håber, at nogen kan hjælpe mig med dette! :)


Mvh
Ulrik
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester