Solved

asp / mysql and form-check

Posted on 2002-03-10
4
404 Views
Last Modified: 2012-08-14
Can You see whats wrong here ? It keep telling me theres no password written in the form. (35 points is all I have)

inc_Signup.asp :

<script language="javascript">
      <!--
            function checkform() {
                  var doSubmit=false;
                  var genderSel=false;

                  for (var i=0; i<3; i++) {
                        if (frmSignup.gender[i].checked) { genderSel=true; }
                  }

                  if (frmSignup.pass.value=="") {
                        alert("Du skal indtaste at password!");
                  } else if (frmSignup.email.value=="") {
                        alert("Du skal indtaste din email adresse!");
                  } else if (frmSignup.fullname.value=="") {
                        alert("Du skal skrive dit navn!");
                  } else if (!genderSel) {
                        alert("Du skal vælge et køn!");
                  } else if (frmSignup.filename.value=="") {
                        alert("Du skal vælge et billede til din profil!");
                  } else {
                        frmSignup.submit();
                  }
            }
      //-->
</script>
For at deltage med dit eget billede, er det nødvendigt at vi modtager lidt oplysninger om dig, samt dit billede - udfyld venligst nedenstående formular, og derefter er du automatisk med i afstemningen :<br><br>
<center>
      <form action="signup_save.asp" name="frmSignup" method="post" enctype="multipart/form-data">
      <input type="hidden" name="mode" value="login">
      <table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr><td colspan="2"><b>Følgende informationer forbliver hemmelige : </b></td></tr>
            <tr><td colspan="2">&nbsp;</td></tr>
            <tr>
                  <td width="125"><b>Password:</b></td>
                  <td><input name="pass" class="btn" size="20"></td>
            </tr>
            <tr>
                  <td><b>E-Mail:</b></td>
                  <td><input size="50" name="email" class="btn"></td>
            </tr>
            <tr><td colspan="2">&nbsp;</td></tr>
            <tr><td colspan="2"><b>Følgende informationer bliver synlige på din profil side : </b></td></tr>
            <tr><td colspan="2">&nbsp;</td></tr>
            <tr>
                  <td><b>Navn:</b></td>
                  <td><input size="50" name="fullname" class="btn"></td>
            </tr>
            <tr>
                  <td>Bynavn:</td>
                  <td><input size="50" name="homecity" class="btn"></td>
            </tr>
            <tr>
                  <td>Land:</td>
                  <td><input size="50" name="homecountry" class="btn"></td>
            </tr>
            <tr>
            <td vAlign=top>Teaser tekst:</td>
            <td><textarea name="teaser" rows="5" cols="50" class="btn"></textarea></td></tr>
            <tr>
                  <td><b>Køn:</b></td>
                  <td><input type="radio" value="2" name="gender">Mand<input type="radio" value="1" name="gender">Kvinde<input type="radio" value="3" name="gender">Barn</td>
            </tr>
            <tr>
                  <td valign="top"><b>Billede:</b></td>
                  <td>
                        <input type="file" size="40" name="filename" class="btn"> (max. <%=MaxFileSize \ 1024%> KB)<br>
                        <b>Bemærk:</b> Det er kun tilladt at uploade .JPG og .PNG billeder!
                  </td>
            </tr>
            <tr><td colspan="2"><hr class="gray_hr"></td></tr>
            <tr>
                  <td>&nbsp;</td>
                  <td><input type="button" value="Tilføj billede" class="btn" onclick="checkform();"></td>
            </tr>
      </table>
      </form>
</center>


Singup_save.asp


<%
      On Error Resume Next
dim PUpload
      Set PUpload = Server.CreateObject("AspSmartUpload.SmartUpload")
      PUpload.MaxFileSize = MaxFileSize
      PUpload.AllowedFilesList = "jpg,jpeg,png"
      PUpload.Upload
      If Err <> 0 Then
            If Err = -2147220494 Then intErrorCode = 20
            If Err = -2147220399 Then intErrorCode = 21
            Err.Clear
      End If

      If Not PUpload.Files("filename").IsMissing And intErrorCode = 0 Then
            Set Conn = Server.CreateObject("ADODB.Connection")
            Conn.Open "DRIVER=mysql; SERVER=" & sql_Server & "; DATABASE=" & sql_DB & "; UID=" & sql_UID & "; PWD=" & sql_PWD

            strPass = DeMessSQL(Trim(PUpload.Form("pass")))
            strEmail = DeMessSQL(Trim(PUpload.Form("email")))
            strName = DeMessSQL(Trim(PUpload.Form("fullname")))
            strCity = DeMessSQL(Trim(PUpload.Form("homecity")))
            strCountry = DeMessSQL(Trim(PUpload.Form("homecountry")))
            strText = DeMessSQL(Trim(PUpload.Form("teaser")))
            strGender = DeMessSQL(Trim(PUpload.Form("gender")))
            strFilename = PUpload.Files("filename").FileName
            
            If strGender = "" Or Not IsNumeric(strGender) Then intErrorCode = 3
            If strEmail = "" Or Not IsEmail(strEmail) Then intErrorCode = 2
            Set Rs = Conn.Execute("SELECT id FROM persons WHERE email='" & strEmail & "'")
            If Not Rs.BOF Then intErrorCode = 4
            If strPass = "" Then intErrorCode = 1

            If intErrorCode = 0 Then
                  strSQL = "INSERT INTO persons (password,email,name,city,country,text,gender,picturefile,datetime,shown) VALUES ("
                  strSQL = strSQL & "PASSWORD('" & strPass & "'),"
                  strSQL = strSQL & "'" & strEmail & "',"
                  strSQL = strSQL & "'" & strName & "',"
                  strSQL = strSQL & "'" & strCity & "',"
                  strSQL = strSQL & "'" & strCountry & "',"
                  strSQL = strSQL & "'" & strText & "',"
                  strSQL = strSQL & strGender & ","
                  strSQL = strSQL & "'" & strFilename & "',"
                  strSQL = strSQL & "now(),0);"

                  Conn.Execute strSQL
                  Set Rs = Conn.Execute("SELECT id FROM persons ORDER BY id DESC")
                  strPID = Rs(0)

                  strMail = strEMVO
                  strMail = Replace(strMail, "#navn", strName)
                  strMail = Replace(strMail, "#pid", strPID)

                  PUpload.Files("filename").SaveAs Server.MapPath("db/pictures/" & strPID & "_" & strFilename)
                  If Err = 0 Then
                        ResizeIImage Server.MapPath("db/pictures/" & strPID & "_" & strFilename), 615
                        Conn.Execute "INSERT INTO hits (pid) VALUES (" & strPID & ");"
                        SendMail strEmail, "Registrering på Hot Or Not", strMail
                  Else
                        Conn.Execute "DELETE FROM persons WHERE id=" & strPID
                        intErrorCode = 30
                  End If
            End If
      ElseIf intErrorCode = 0 Then
            intErrorCode = 40
      End If
%>



0
Comment
Question by:Capion
  • 2
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
third earned 40 total points
ID: 6855290
maybe you didn't fill the password field. i tried ur code it only asks when it isn't filled. so what is the real problem? can u elaborate?

btw, password characters are usually ciphered when you type in the field. so i suggest (for the your user's protection) put,

<input name="pass" type="password" class="btn" size="20">
0
 
LVL 1

Author Comment

by:Capion
ID: 6855767
yes, I thought it was because of the *** the error came, so I changed it to a normal text-field.
I tried it also (the code I put in here), and the form works..well hmm..
There must be something else wrong then.

http://www.capion.dk/db/defaulthot.asp?mode=signup

I didn´t bring the whole code, because I didn´t think it was relevant, its only html.
0
 
LVL 30

Expert Comment

by:third
ID: 6858831
C???
0
 
LVL 1

Author Comment

by:Capion
ID: 6861109
ehm.. I gave up, thought You should have the point for trying *S*
I will find some other way to set up a photo-voting-booth.
It quite hard to find a script other than cgi or php and mysql. This particular one was in asp and mysql.
Mayby You have a link to a working script ? (á la hot or not)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now