Avatar billede lbos Nybegynder
27. marts 2003 - 10:40 Der er 6 kommentarer og
1 løsning

Hjælp kan ikk finde uf af et !!!

Hej alle
jeg har en side hvor man kan logge sig ind det som jeg godt kunne tænke mig er at når man er oprettet sender den en email til den nye bruger med oplysninger om brugernavn email etc. jeg har en opret.asp og signupprocess.asp jeg har forsøgt lidt selv men det virker ikke her er den rigtige signupprocess.asp :

<%
Option Explicit
Dim sql, vagt, hojde, hafarve, ojfarve,stemmer, ryger, landsdel, brn,gft,anon,vgplan,tlfkli,mobkli,adr, hbb, msk, stng, dd, sexorient, ptype, udsende, biled,FILENAME,rsUser,username,password,passwordconfirm,firstname,surname,email,dob,sex,profil,seek,notfilled(9),badflag,count,passwordLength,calltype,icon,starsign,dobmonth,dobday

'Assign form values to variables
username = Request.Form("username")

'Make sure they've not put any quotation marks in their username
If InStr(username,chr(34)) <> 0 or InStr(username,chr(39)) <> 0 then
    errorfunction("invalidchars")
end if

firstname = Request.Form("firstname")
surname = Request.Form("surname")
email = Request.Form("email")
sex = Request.Form("sex")
seek = Request.Form("seek")
password = Request.Form("password")
passwordconfirm = Request.Form("passwordconfirm")
dob = Request.Form("birth_day") & "/" & Request.Form("birth_month") & "/" & Request.Form("birth_year")
icon = Request.Form("icon")
biled = Request.Form("biled")
profil = Request.Form("profil")
vagt = Request.Form("vagt")
hojde = Request.Form("hojde")
hafarve = Request.Form("hafarve")
ojfarve = Request.Form("ojfarve")
ryger = Request.Form("ryger")
landsdel = Request.Form("landsdel")
sexorient = Request.Form("sexorient")
ptype = Request.Form("ptype")
udsende = Request.Form("udsende")
brn = Request.Form("brn")
msk = Request.Form("msk")
gft = Request.Form("gft")
dd = Request.Form("dd")
hbb = Request.Form("hbb")
stng = Request.Form("stng")
tlfkli = Request.Form("tlfkli")
mobkli = Request.Form("mobkli")
adr = Request.Form("adr")
anon = Request.Form("anon")
vgplan = Request.Form("vgplan")
stemmer = Request.Form("stemmer")
'Check everything's been filled in, badflag determines whether error function is called
badflag = 0

'nofilled() is an array that will store the fields which are not filled in

if landsdel = "" then
    notfilled(0) = "landsdel"
    badflag = 1
end if
if surname = "" then
    notfilled(1) = "Surname"
    badflag = 1
end if
if email = "" then
    notfilled(2) = "Email"
    badflag = 1
end if
if username = "" then
    notfilled(3) = "Username"
    badflag = 1
end if
if password = "" then
    notfilled(4) = "Password"
    badflag = 1
end if
if sex = "" then
    notfilled(5) = "Sex"
    badflag = 1

end if
if icon = "" then
    notfilled(6) = "Your choice of icon"
    badflag = 1
end if

if badflag = 1 then
    signuperror()
end if

'Check password length is between 5 and 15 characters long
passwordLength = Len(password)
if passwordLength < 5 or passwordLength > 15 then
    errorfunction("length")
end if

'Check password and confirmed password are the same
if password <> passwordconfirm then
    errorfunction("confirm")
end if
'Open connection and insert user details into the database
%><!--#include file="conn.asp"--><%

'For a bit of profiling fun, get their star sign
getstarsign()
getbiled()
'Then add it to the database. It's in a seperate function because we need to error trap to see if there's been a duplicate entry. It's not good form to have On Error Resume Next throughout your whole page

UserUpdate()

Function UserUpdate()
On Error Resume Next

Set rsUser = Server.CreateObject("ADODB.Recordset")
rsUser.open "users", conn, 3, 3
rsUser.AddNew
rsUser("username") = username
rsUser("password") = password
rsUser("firstname") = firstname
rsUser("surname") = surname
rsUser("email") = email
rsUser("dob") = dob
rsUser("starsign") = starsign
rsUser("sex") = sex
rsUser("icon") = icon
rsUser("lookfor")= seek
rsUser("FILENAME")= biled
rsUser("profil")= profil
rsUser("vagt") = vagt
rsUser("hojde") = hojde
rsUser("hafarve") = hafarve
rsUser("ojfarve") = ojfarve
rsUser("ryger") = ryger
rsUser("landsdel") = landsdel
rsUser("sexorient") = sexorient
rsUser("udsende") = udsende
rsUser("ptype") = ptype
rsUser("brn") = brn
rsUser("msk") = msk
rsUser("gft") = gft
rsUser("dd") = dd
rsUser("hbb") = hbb
rsUser("stng") = stng
rsUser("tlfkli") = tlfkli
rsUser("mobkli") = mobkli
rsUser("adr") = adr
rsUser("anon") = anon
rsUser("vgplan") = vgplan
rsUser("stemmer") = stemmer

rsUser.Update


if Err.Number = -2147217887 then
    Err.clear
    errorfunction("badusername")
else
    'Set username cookie to sign them in now
    Response.Cookies("username") = username
%><html>

<head>
<title></title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="robots" content="index, follow">
<meta name="revisit" content="7 days">
<style type="text/css">
<!--

    A:link {text-decoration: none;}
    A:visited {text-decoration: none;}
    A:hover {text-decoration: underline;}

-->
</style>
</head>

<body bgcolor="#F8AC50" text="000000" link="FF8000" vlink="FF8000" marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>
<table border=0 cellpadding=0 cellspacing=0 bgcolor="#CCCCCC">
    <tr>
        <td valign=top height="486">
            <p>&nbsp;</p>
        </td>
        <td valign=top height="486" bgcolor="#F8D098">
            <p>&nbsp;</p>
            <p align="center"><font color="#81522F"><br></font>
            <table align="center" border="0" width="85%">
                <tr>
                    <td>
                        <p align="center"><font color="#81522F">&nbsp;</font>
                        <p><font face="arial,helvetica" size=2 color="#81522F"><b>Tak
                        for det <%=username%> </b></font></p>
                        <p><font face="arial,helvetica" size=2 color="#81522F"><b>Du
                        har brugernavn <%=username%> Og du er logget ind!</b></font></p>
                        <p><a href="profile.asp" target="_blank" onclick="java script:self.close()">Klik
                        her for at forsætte...</a>
                        <p><font color="#81522F">&nbsp;</font></td>
                </tr>
            </table>
            <ul>
                <%
rsUser.close
set rsUser = nothing
conn.close
set conn = nothing
%><%
end if
End Function%><%
Function getbiled()
biled = Request.Form("biled")
username = Request.Form("username")
Select Case username
    Case username
        if biled = "test" then
            FILENAME = "no_image.jpg"
        else
            FILENAME = "no_image.jpg"
        end if
End Select
End Function
%><%
Function getstarsign()
dobmonth = Request.Form("birth_month")
dobday = Request.Form("birth_day")
Select Case dobmonth
    Case 1
        if dobday < 21 then
            starsign = "Stenbuk"
        else
            starsign = "Vandmand"
        end if
    Case 2
        if dobday < 20 then
            starsign = "Vandmand"
        else
            starsign = "Fisk"
        end if
    Case 3
        if dobday < 21 then
            starsign = "Fisk"
        else
            starsign = "Vædder"
        end if
    Case 4
        if dobday < 21 then
            starsign = "Vædder"
        else
            starsign = "Tyr"
        end if
    Case 5
        if dobday < 22 then
            starsign = "Tyr"
        else
            starsign = "Tvilling"
        end if
    Case 6
        if dobday < 22 then
            starsign = "Tvilling"
        else
            starsign = "Krebs"
        end if
    Case 7
        if dobday < 24 then
            starsign = "Krebs"
        else
            starsign = "Løve"
        end if
    Case 8
        if dobday < 24 then
            starsign = "Løve"
        else
            starsign = "Jomfru"
        end if
    Case 9
        if dobday < 24 then
            starsign = "Jomfru"
        else
            starsign = "Vægten"
        end if
    Case 10
        if dobday < 24 then
            starsign = "Vægten"
        else
            starsign = "Skorpion"
        end if
    Case 11
        if dobday < 23 then
            starsign = "Skorpion"
        else
            starsign = "Skytte"
        end if
    Case 12
        if dobday < 22 then
            starsign = "Skytte"
        else
            starsign = "Stenbuk"
        end if
End Select
End Function
%><%Function signuperror()%>
                <p><font face="arial,helvetica" size=2 color="#81522F"><b>UPS
                du mangler lige nogle ting :</b></font></p>
                <%for count = 0 to 7%><%if notfilled(count) <> "" then%><%=notfilled(count)%><font face="arial,helvetica" size=2><br>
                <%end if%> <%next%> </font>
                <p><font face="arial,helvetica" size=2><a href="java script:self.history.go(-1)">Prøv
                igen</a></font></p>
                <%Response.end
End Function%><%Function errorfunction(calltype)%><%if calltype = "confirm" then%>
                <p><font face="arial,helvetica" size=2 color="#81522F"><b>De
                to password passer ikke sammen</b></font></p>
                <p><font face="arial,helvetica" size=2><a href="java script:self.history.go(-1)">Prøv
                igen</a></font></p>
                <%Response.end%><%elseif calltype = "length" then%>
                <p><b><font color="#81522F">Password skal være mellem 5 og 15
                karakter i længde</font></b></p>
                <p><a href="java script:self.history.go(-1)">Prøv igen</a></p>
                <%Response.end%><%elseif calltype = "badusername" then%>
                <p><b><font color="#81522F">Ufff !!! &quot;<%=username%>&quot;
                er allerede brugt.</font></b></p>
                <p><a href="java script:self.history.go(-1)">Prøv igen</a></p>
                <%
rsUser.close
set rsUser = nothing
conn.close
set conn = nothing
Response.end
%><%elseif calltype = "invalidchars" then%>
                <p><b><font color="#81522F">Brugernavnet må ikke indeholde quotering</font></b></p>
                <p><a href="java script:self.history.go(-1)">Prøv igen</a></p>
                <p align="left">&nbsp;</p>
            </ul>
        </td>
    </tr>
</table>
<p>&nbsp;</p>
</body>

</html>
<%Response.end%><%end if
End Function%>

der er en del svar på dette spørgsmål på eksperten de funger sikkert fint men jeg kan ikke finde ud af hvor og hvor jeg skal lægge dem .Jeg har 200 point på højkant håber det er nok !! ;O)
Avatar billede krsk Nybegynder
27. marts 2003 - 10:48 #1
Skær alt det overflødige væk! Det er umuligt at arbejde med hvis du er ny og vi skal hjælpe :-)

Så fjern alt som ikke har med brugernavn og password at gøre. Så er jeg sikker på du for bedre resultat her.

Jeg kigger forbi senere...

/Kristian
Avatar billede lbos Nybegynder
27. marts 2003 - 10:55 #2
Så prøver vi det
dette er toppen af signupprocess :

Option Explicit
Dim sql, vagt, hojde, hafarve, ojfarve,stemmer, ryger, landsdel, brn,gft,anon,vgplan,tlfkli,mobkli,adr, hbb, msk, stng, dd, sexorient, ptype, udsende, biled,FILENAME,rsUser,username,password,passwordconfirm,firstname,surname,email,dob,sex,profil,seek,notfilled(9),badflag,count,passwordLength,calltype,icon,starsign,dobmonth,dobday

'Assign form values to variables
username = Request.Form("username")

'Make sure they've not put any quotation marks in their username
If InStr(username,chr(34)) <> 0 or InStr(username,chr(39)) <> 0 then
    errorfunction("invalidchars")
end if

firstname = Request.Form("firstname")
surname = Request.Form("surname")
email = Request.Form("email")
sex = Request.Form("sex")
seek = Request.Form("seek")
password = Request.Form("password")
passwordconfirm = Request.Form("passwordconfirm")
dob = Request.Form("birth_day") & "/" & Request.Form("birth_month") & "/" & Request.Form("birth_year")
icon = Request.Form("icon")
biled = Request.Form("biled")
profil = Request.Form("profil")
vagt = Request.Form("vagt")
hojde = Request.Form("hojde")
hafarve = Request.Form("hafarve")
ojfarve = Request.Form("ojfarve")
ryger = Request.Form("ryger")
landsdel = Request.Form("landsdel")
sexorient = Request.Form("sexorient")
ptype = Request.Form("ptype")
udsende = Request.Form("udsende")
brn = Request.Form("brn")
msk = Request.Form("msk")
gft = Request.Form("gft")
dd = Request.Form("dd")
hbb = Request.Form("hbb")
stng = Request.Form("stng")
tlfkli = Request.Form("tlfkli")
mobkli = Request.Form("mobkli")
adr = Request.Form("adr")
anon = Request.Form("anon")
vgplan = Request.Form("vgplan")
stemmer = Request.Form("stemmer")
'Check everything's been filled in, badflag determines whether error function is called
badflag = 0

'nofilled() is an array that will store the fields which are not filled in

if landsdel = "" then
    notfilled(0) = "landsdel"
    badflag = 1
end if
if surname = "" then
    notfilled(1) = "Surname"
    badflag = 1
end if
if email = "" then
    notfilled(2) = "Email"
    badflag = 1
end if
if username = "" then
    notfilled(3) = "Username"
    badflag = 1
end if
if password = "" then
    notfilled(4) = "Password"
    badflag = 1
end if
if sex = "" then
    notfilled(5) = "Sex"
    badflag = 1

end if
if icon = "" then
    notfilled(6) = "Your choice of icon"
    badflag = 1
end if

if badflag = 1 then
    signuperror()
end if

'Check password length is between 5 and 15 characters long
passwordLength = Len(password)
if passwordLength < 5 or passwordLength > 15 then
    errorfunction("length")
end if

'Check password and confirmed password are the same
if password <> passwordconfirm then
    errorfunction("confirm")
end if
'Open connection and insert user details into the database
%><!--#include file="dben.asp"--><%----------------

og dette er opret.asp



Option Explicit
Dim username,newcount

username = Request.Cookies("username")
%><html>

<head>
<title>Opret gratis profil</title>
<meta name="generator" content="Namo WebEditor v4.0">
<link rel="stylesheet" href="design7.css">
<script language="JavaScript">
<!--
function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';
  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

// -->
</script>
</head>

<body body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" body oncontextmenu="return false;" bgcolor="#9EB2BD" onload="na_open_window('win', 'logbeting.asp', 400, 200, 450, 420, 0, 0, 0, 0, 0);">
<table border=0 cellspacing=0 cellpadding=0 bgcolor=#FFFFFF width="445" align="center" style="border-width:1; border-color:rgb(129,82,47); border-style:solid;">
    <tr>
        <td height="5"><font face="Verdana" size="2" color="#81522F"><img src="i/s.gif" width=1 height=9 border=0></font></td>
    </tr>
    <tr>
        <td valign=top class="csMainHead">
            <p align="center"><img src="nologin_asp_smartbutton1.gif" border="0"><br><font color="#81522F" size="2"><%'See if they're actually already logged in
if username <> "" then%></font><font face="arial,helvetica" size="2" color="#81522F">Du
            er allerede logget ind.Hvis du vil registrerer dig igen <br>så </font><a href="signout.asp"><font face="arial,helvetica" size="2" color="#81522F">log
            ud her </font></a><font face="arial,helvetica" size="2" color="#81522F">først.</font><font color="#81522F" size="2"><%'Otherwise display the sign up form
else%></font></td>
    </tr>
    <tr>
        <td><font face="Verdana" size="2" color="#81522F"><img src="i/s.gif" width=1 height=5 border=0></font></td>
    </tr>
    <tr>
        <td><font face="Verdana" size="2" color="#81522F"><img src="i/l2.gif" width=422 height=1 border=0></font></td>
    </tr>
    <tr>
        <td>
            <table border=0 cellspacing=0 cellpadding=0 align="center" width="428">
                <form name="signup" action="signupprocess.asp" method="post">
                    <tr>
                        <td colspan="2" bgcolor="#FCCF9C" width="428"><font face="Verdana" size="2" color="#81522F"><img src="i/s.gif" width=1 height=4 border=0></font></td>
                    </tr>
                    <tr>
                        <td bgcolor="#FCCF9C" width="9"><font face="Verdana" size="2" color="#81522F">&nbsp;&nbsp;</font></td>
                        <td width="419" bgcolor="#FCCF9C"><font face="Verdana" size="2" color="#81522F">Brugernavn</font></td>
                    </tr>
                    <tr>
                        <td colspan="2" bgcolor="#FCCF9C" width="428"><font face="Verdana" size="2" color="#81522F"><img src="i/s.gif" width=1 height=5 border=0></font></td>
                    </tr>
                    <tr>
                        <td bgcolor="#FCCF9C" width="9"><font face="Verdana" size="2" color="#81522F">&nbsp;&nbsp;</font></td>
                        <td width="419" bgcolor="#FCCF9C"><font face="Verdana" size="2" color="#81522F"><input maxlength=25 type=text name="username" value="" onkeypress="return nicknamecheck(event);" size="20" style="border-width:1; border-color:rgb(129,82,47); border-style:solid;"></font></td>
                    </tr>
                    <tr>
                        <td colspan="2" bgcolor="#FCCF9C" width="428"><font face="Verdana" size="2" color="#81522F"><img src="i/s.gif" width=1 height=4 border=0></font></td>
                    </tr>
                    <tr>
                        <td colspan="2" width="428"><font face="Verdana" size="2" color="#81522F"><img src="i/s.gif" width=1 height=2 border=0></font></td>
                    </tr>
                    <tr>
                        <td colspan="2" bgcolor="#FCCF9C" width="428"><font face="Verdana" size="2" color="#81522F"><img src="i/s.gif" width=1 height=4 border=0></font></td>
                    </tr>
                    <tr>
                        <td bgcolor="#FCCF9C" width="9"><font face="Verdana" size="2" color="#81522F">&nbsp;&nbsp;</font></td>
                        <td width="419" bgcolor="#FCCF9C"><font face="Verdana" size="2" color="#81522F">Adgangskode</font></td>
                    </tr> etc---............
er dette bedre ?
Avatar billede krsk Nybegynder
27. marts 2003 - 10:59 #3
Nej :-)

Alt dette er vel næppe nødvendigt for at få det til at virke:

email = Request.Form("email")
sex = Request.Form("sex")
seek = Request.Form("seek")
password = Request.Form("password")
passwordconfirm = Request.Form("passwordconfirm")
dob = Request.Form("birth_day") & "/" & Request.Form("birth_month") & "/" & Request.Form("birth_year")
icon = Request.Form("icon")
biled = Request.Form("biled")
profil = Request.Form("profil")
vagt = Request.Form("vagt")
hojde = Request.Form("hojde")
hafarve = Request.Form("hafarve")
ojfarve = Request.Form("ojfarve")
ryger = Request.Form("ryger")
landsdel = Request.Form("landsdel")
sexorient = Request.Form("sexorient")
ptype = Request.Form("ptype")
udsende = Request.Form("udsende")
brn = Request.Form("brn")
msk = Request.Form("msk")
gft = Request.Form("gft")
dd = Request.Form("dd")
hbb = Request.Form("hbb")
stng = Request.Form("stng")
tlfkli = Request.Form("tlfkli")
mobkli = Request.Form("mobkli")
adr = Request.Form("adr")
anon = Request.Form("anon")
vgplan = Request.Form("vgplan")
stemmer = Request.Form("stemmer")

Du skal nøjes med to felter (eller PRÆCIS det der skal til)

Så bygger vi på derfra.

Al tabel snasket smid det ud også.

/Kristian :-)
Avatar billede lbos Nybegynder
27. marts 2003 - 11:03 #4
<%
Option Explicit
Dim sql, vagt, hojde, hafarve, ojfarve,stemmer, ryger, landsdel, brn,gft,anon,vgplan,tlfkli,mobkli,adr, hbb, msk, stng, dd, sexorient, ptype, udsende, biled,FILENAME,rsUser,username,password,passwordconfirm,firstname,surname,email,dob,sex,profil,seek,notfilled(9),badflag,count,passwordLength,calltype,icon,starsign,dobmonth,dobday

'Assign form values to variables
username = Request.Form("username")

'Make sure they've not put any quotation marks in their username
If InStr(username,chr(34)) <> 0 or InStr(username,chr(39)) <> 0 then
    errorfunction("invalidchars")
end if

firstname = Request.Form("firstname")
surname = Request.Form("surname")
email = Request.Form("email")
Avatar billede krsk Nybegynder
27. marts 2003 - 15:31 #5
Hej igen

Jeg vil mene at du skal bruge sådan noget som dette:

Set objSend = Server.CreateObject("CDONTS.Newmail")
objSend.From = Request ("From")
objSend.To = Request ("EmailTo")
objSend.Subject = Request ("Subject")

strBodyHeader= "This form was sent via e-mail on bla bla bla"
strBody = strBodyHeader & strBody
objSend.Body = strBody

BTW: Forstår du hvad jeg mener når jeg siger rydde op? Det er ikke for bare ukritisk smide væk, men at have en metodisk tilgang til at teste noget som man ikke ved hvordan virker. Derfor lad være med at have en masse skidt med som ikke er relevant for den test du vil udføre.

Se på din DIM deklaration, har du brug for alle dem? Osv. Start med at lave en side som har nogle statiske felter som når du eksekverer den sender en e-mail til dig selv...når det virker er det ikke svært at bygge den om det at være dynamisk...Jeg hjælper dig gerne.

Prøv at lave den simple side først.

/Kristian
Avatar billede krsk Nybegynder
27. marts 2003 - 15:35 #6
Ups. mit eksemper kræver at man har noget tredieparts stuff installeret...:

Her er der et eksempel uden: http://www.parcom.net/support/aspemail_sample.htm
Avatar billede lbos Nybegynder
27. marts 2003 - 15:48 #7
hej
jeg kan meget godt forstå der er fpr meget overflødigt men først og fremmest har jeg ikke cdonts men jmail og hvor skal jeg lægge det ind ??
Uden at genere det andet ?
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