Avatar billede malte Nybegynder
27. juli 2003 - 13:06 Der er 2 kommentarer og
1 løsning

Et stort script ?

Jeg ved godt dette script er stort og jeg har forsøgt at sætte Jmail ind istedet for Cdonts. De ander steder på sitet er det gået og med her hvor man melder sig ind for at søge job er det gået helt galt. Mailen bliver ikke sendt og jeg får "variable undefined" som fejl.
Avatar billede malte Nybegynder
27. juli 2003 - 13:08 #1
<%@ Language=VBScript %>
<% Option Explicit %>

<!--#INCLUDE FILE="./includes/APPsettings.asp"-->

<%

Dim sEmailAddress
Dim sCompanyName
Dim sLastName
Dim sFirstName
Dim sConfirm
Dim sUserID
Dim sSQL        'In sub CheckName
Dim MyRSCount
Dim sErrorFlag
Dim sPassword
Dim npSQL
Dim Mail
Dim s_Mail_Body,sEmpStatus

sEmailAddress = Request.Form("sEmailAddress")
sLastName = Request.Form("sLastName")
sFirstName = Request.Form("sFirstName")
sUserID = Request.Form("sUserID")
sConfirm = Request.Form("sConfirm")
sEmpStatus = Request.Form("sEmpStatus")
sCompanyName = Request.Form("sCompanyName")
   



  %>




<html>
<head>




<title>Counselor.dk - Jobs </title>
<meta http-equiv="Content-Type" content="text/html;">

<script language="JavaScript">
<!--
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];}
}
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.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}
//-->
</script>
<link rel="stylesheet" href="CSS/CSS1.css" type="text/css">
</head>
<body bgcolor="#ffffff" onLoad="MM_preloadImages('images/iAmJobs_r2_c4_f2.jpg','images/iAmJobs_r2_c5_f2.jpg','images/iAmJobs_r2_c6_f2.jpg','images/iAmJobs_r2_c7_f2.jpg');" leftmargin="0" topmargin="0">
<!--#include file="includes/Top_of_Page.asp" -->

<table border="0" cellpadding="0" cellspacing="0" width="755" align="center">
  <tr>
    <td align="right" valign="top" width="162">
      <table width="130" border="0" cellspacing="0" cellpadding="4">
        <tr>
          <td align="left" valign="top">
            <p><font face="Arial, Helvetica, sans-serif" size="1">All Members
              log in to view their account details and to see the contact information
              of employers or job hunters.</font></p>

            <form name="form33" method="post" action="./login.asp">
              <div align="center">
               
              <input type="submit" name="Joined" id="Joined" value="Members Go Here" style="font: 8pt verdana;background-color:'Green';border-color:'green';width:115;color='ffffff'">

                </div>
            </form>           


            </td>
        </tr>
</table>


    </td>
    <td rowspan="3" background="images/iAmJobs_r3_c2.jpg">&nbsp;</td>
    <td rowspan="3" colspan="6" align="left" valign="top">
      <table width="100%" border="0" cellspacing="3" cellpadding="4">
        <tr align="left" valign="top">
          <td width="50%">
            <table width="75%" border="0" cellspacing="3" cellpadding="4" align="center">
              <tr>
                <td>
                  <%
Call ErrorTrapping


Sub ErrorTrapping

    sErrorFlag = ""
   
    '#Error Trapping, looking for empty form fields
    IF sEmailAddress <= "" OR Len(Trim(sEmailAddress))<7 THEN
        sErrorFlag = sErrorFlag & "The <b>email address</b> is missing or too short.<BR>"
    END IF

    IF sLastName <= "" OR Len(Trim(sLastName))<3  THEN
        sErrorFlag = sErrorFlag & "Your <b>Last Name</b> is missing or too short.<BR>"
    END IF

    IF sFirstName <= "" OR Len(Trim(sFirstName))<3 THEN
        sErrorFlag = sErrorFlag & "Your <b>First Name</b> is missing or too short<BR>"
    END IF

    IF sUserID <= "" OR Len(Trim(sUserID))<3 THEN
        sErrorFlag = sErrorFlag & "Your <b>UserID</b> is missing or too short.<BR>"
    END IF
   
    IF sEmpStatus <= "" THEN
        sErrorFlag = sErrorFlag & "Your <b>Status</b> must indicate if you are a Job Seeker or Employer.<BR>"
    END IF
    IF sEmpStatus = "Employer" THEN
        IF sCompanyName <= ""THEN
            sErrorFlag = sErrorFlag & "Your <b>Company Name</b> must be provided.<BR>"
        END IF
    END IF
    IF Len(Trim(sErrorFlag)) > 0 THEN
        'errors were found
        Response.Write ("<p>"& sErrorFlag &"</p>")
               
            %>       
           
            <%  IF sEmpStatus = "Employee" THEN %>
                        <form name="form33" method="post" action="./placeAd.asp"><div align="center"><input type="submit" name="Joined" id="Joined" value="Try Again..." style="font: 8pt verdana;background-color:'Yellow';border-color:'green';width:115;color='black'"></div></form>
            <%  ELSE %>
                        <form name="form33" method="post" action="./Employers.asp"><div align="center"><input type="submit" name="Joined" id="Joined" value="Try Again..." style="font: 8pt verdana;background-color:'Yellow';border-color:'green';width:115;color='black'"></div></form>

            <%
                END IF
       
    ELSE
        'no errors so check the userid
        Call CheckName
   
    END IF
   
End Sub


Sub CheckName
    sSQL = ""
    sSQL = sSQL & "SELECT * FROM tbl_People WHERE People_UserID = '" & sUserID &"';"
    Set MyRSCount = MyConn.Execute(sSQL) 
        If MyRSCount.EOF AND MyRSCount.BOF Then
            'Call the update cause the userid isn't in the database already
            Call InsertUser
        Else
            'we are not BOF and EOF so the userid must already exist so...
            Response.Write("<h1>UserID Exists!</h1>")
            Response.Write("<p>The User Name you chose," & chr(34) & "<B>"  & sUserID & "</B>" & chr(34) & ", has already been taken.<BR>")
           
            %>       
            <form name="form33" method="post" action="./placeAd.asp"><div align="center"><input type="submit" name="Joined" id="Joined" value="Try Again..." style="font: 8pt verdana;background-color:'Yellow';border-color:'green';width:115;color='black'"></div></form>
            <%
             
               
             
               
           
        End If     
End Sub



Sub InsertUser
    'Removed for debug only...Response.Write("Insert has been called!!!")


Randomize
    sPassword = clng(rnd * 10000000) + 1915
        npSQL = ""
        npSQL = npSQL & " INSERT INTO tbl_People (People_UserID, People_PassWord, People_LastName, People_FirstName, People_Email, People_BusinessName, People_EmpStatus) "
        npSQL = npSQL & " VALUES (" & SQLStr(sUserID) & ", "
        npSQL = npSQL & SQLStr(sPassword) & ", "
        npSQL = npSQL & SQLStr(sLastName) & ", "
        npSQL = npSQL & SQLStr(sFirstName) & ", "
        npSQL = npSQL & SQLStr(sEmailAddress) & ", "
        npSQL = npSQL & SQLStr(sCompanyName) & ", "
        npSQL = npSQL & SQLStr(sEmpStatus)& " )"

        ' Removed for debug only...
        'Response.Write npSQL

        MyConn.Execute(npSQL)

           
        Response.Write("<h1>Thanks For Joining!</h1>")
        Response.Write("<p>Your registration has been completed successfully.<BR>")
          Response.Write("Your password has been emailed to you.<BR>")
        Response.Write("You can change your password by clicking on the ""Modify Personal Details"" link.<BR>")
        Response.Write("<A HREF=""default.asp"">Click here</A> to continue.</p>")



    Call SendPassEmail
End Sub



Sub SendPassEmail
   
        On Error Resume Next
'---------------Her har jeg sat Jmail ind----------------------------------   
        set Message = Server.CreateObject( "JMail.Message" )
        message.Logging = true
        If Err.Number = 0 Then   

        Message.From = "Webmaster@counselor.dk"
       
   
        Message.AddRecipient sEmailAddress
        Message.Subject = "Counselor.dk - jobbasen, registrering"


    s_Mail_Body = ""            ' Start to build the mail body here
    s_Mail_Body = s_Mail_Body & "Your account as an "&sEmpStatus&" is now ready for you to setup. We have opened an account with the name and UserID that you provided:" &vbcrlf&vbcrlf
    s_Mail_Body = s_Mail_Body & "Your UserID is: "& sUserID &vbcrlf
    s_Mail_Body = s_Mail_Body & "Your Password is: "& sPassword &vbcrlf&vbcrlf

    s_Mail_Body = s_Mail_Body & "Go here to login:  http://www.counselor.dk/login.asp"&vbcrlf&vbcrlf

    s_Mail_Body = s_Mail_Body & "When you login the first time, please complete the registration form with your details to finish setting up your account. Once this is done your account will be open. If you have any difficulty with this process please do not hesitate to email support@iamplace.com."&vbcrlf&vbcrlf

    s_Mail_Body = s_Mail_Body & "Our unique service allows employers and job seekers to connect. This is a free service and it is not currently our intent to charge for this service, however we reserve the right to charge a fee at a later time."&vbcrlf&vbcrlf

s_Mail_Body = s_Mail_Body & "Thank you for using Counselor.dk, We appreciate you as a valued customer. COunselor.dk is owned and operated by Counselor.dk , københavn Ø."&vbcrlf&vbcrlf
s_Mail_Body = s_Mail_Body & "The Support Team - sopport@counselor.dk"


        Message.Body = s_Mail_Body

        Message.MSPickupDirectory = "C:\Program Files\Exchsrvr\Mailroot\vsi 1\PickUp\"
    Message.nq
'---------------Her har jeg sat Jmail ind----------------------------------
    END IF

    If Err <> 0 Then
        Response.Write"<P>An Error has occurred sending the mail, please advise the webmaster: "& message.log & Err.Description
          'strError = strError & "<BR>" & message.log
    End If
   
    Call SendNoticeEmail
   
End Sub


Sub SendNoticeEmail
    On Error Resume Next
'---------------Her har jeg sat Jmail ind----------------------------------
    set Message = Server.CreateObject( "JMail.Message" )
    'message.Logging = true
    IF Err.Number = 0 THEN
    Message.AddRecipient "malte@counselor.dk","Jørgen Maltesen"
    Message.From = "Webmaster@counselor.dk"
    Message.Subject = "Counselor.dk - jobbasen, Endnu en registrering :-) :-)"
   
    s_Mail_Body = ""            ' Start to build the mail body here
    s_Mail_Body = s_Mail_Body & "A new "& sEmpStatus &" account has been opened :" &vbcrlf&vbcrlf
    s_Mail_Body = s_Mail_Body & "The requested UserID is: "& sUserID &vbcrlf&vbcrlf&vbcrlf
    s_Mail_Body = s_Mail_Body & "This is a notification that a new account has been established online at iAmJobs.com."&vbcrlf&vbcrlf

    Message.Body = s_Mail_Body

        Message.MSPickupDirectory = "C:\Program Files\Exchsrvr\Mailroot\vsi 1\PickUp\"
    Message.nq

'---------------Her har jeg sat Jmail ind----------------------------------
END IF
    If Err <> 0 Then
    Response.Write"An Error has occurred sending the mail, please advise the webmaster: "& Err.Description
        'strError = strError & "<BR>" & message.log
    End If

End Sub


%>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
        <!--#INCLUDE FILE="./includes/bottomlinks.asp"-->
</td>
  <td><img src="images/spacer.gif" width="1" height="69" border="0"></td>
  </tr>
  <tr>
  <td><img name="iAmJobs_r4_c1" src="images/iAmJobs_r4_c1.jpg" width="162" height="22" border="0"></td>
  <td><img src="images/spacer.gif" width="1" height="22" border="0"></td>
  </tr>
  <tr>
    <td align="right" valign="top">

<table width="130" border="0" cellspacing="0" cellpadding="4">
        <tr>
          <td align="left" valign="top">
              <!--#INCLUDE FILE="./includes/JobSearchButtons.asp"-->
            </td>
        </tr>
      </table>

    </td>
  <td><img src="images/spacer.gif" width="1" height="361" border="0"></td>
  </tr>
</table>
</body>
</html>
Avatar billede malte Nybegynder
27. juli 2003 - 13:09 #2
Ja Ja jeg ved godt det er stort og jeg vil gerne give flere point hvis det kræves :-)
Avatar billede nanosoft00 Nybegynder
28. juli 2003 - 13:09 #3
variable undifined betyder at du ikke har declarer alle dine variabler via "Dim".
det kan evt. være i din include fil.

Dette skal du gøre fordi du på anden linje skriver "Option Explicit" prøv evt. at fjerne denne linje.
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