7 Replies Latest reply on Jan 8, 2009 1:17 AM by Newsgroup_User

    Results from form not coming up

    RMaverick69
      I have a page that has 2 form post functions (retail & distributor). The distributor works as expected but the retail does not return any results nor does it display the expected images. I'm using CS3 for Mac. All the code works as long as the 2 sides are on different pages, but once put together they no longer function as desired. Code is attached: Thanks in advance for any and all assistance.
        • 1. Re: Results from form not coming up
          delaneypub Level 1
          I didn't try your page, but the code you show has both forms named frmRegister, the first one has an id of frmRegister and the second has an id of frmRegister2. The name and id for a form should be the same.
          • 2. Re: Results from form not coming up
            delaneypub Level 1
            I didn't try your page, but the code you show has both forms named frmRegister, the first one has an id of frmRegister and the second has an id of frmRegister2. The name and id for a form should be the same.
            • 3. Re: Results from form not coming up
              Level 7
              On Tue, 23 Dec 2008 19:09:25 +0000 (UTC), "delaneypub"
              <elaine@delaneypublications.com> wrote:

              >I didn't try your page, but the code you show has both forms named frmRegister,
              >the first one has an id of frmRegister and the second has an id of
              >frmRegister2. The name and id for a form should be the same.

              That's not true at all.

              Gary
              • 4. Re: Results from form not coming up
                Level 7
                On Tue, 23 Dec 2008 19:21:33 +0000 (UTC), "delaneypub"
                <elaine@delaneypublications.com> wrote:

                >I didn't try your page, but the code you show has both forms named frmRegister,
                >the first one has an id of frmRegister and the second has an id of
                >frmRegister2. The name and id for a form should be the same.

                I will say it again. There is no requirement for a name to be the same as
                an ID. The name of the form has nothing to do with anything when the form
                is processed. Unfortunately, the brain-dead web forum truncated the code
                such that no form was included. About the only way to troubleshoot this is
                going to be to upload the page and post a link to it.

                Gary
                • 5. Re: Results from form not coming up
                  RMaverick69 Level 1
                  What do you need to test? Here's the actual code for the form:

                  <form action="home_depot_new.asp" method="post" name="frmRegister" id="frmRegister" onsubmit="return validate()">
                  <p> <b><font color="#000099" class="txt1">Search
                  By Zip Code </font></b>
                  <input type="text" name="searchzipcode" size="20" />
                  <input type="hidden" value="search" name="actiontype" />
                  <input type="submit" value="Search" name="B1" />
                  </p>
                  </form>


                  Here's the asp form file:

                  <form name="frmRegister" method="POST" action="home_depot_new.asp" onsubmit="return validate()">

                  <p>
                  <b><font color="#000099" class="txt1">Search
                  By Zip Code </font></b>
                  <input type="text" name="searchzipcode" size="20">
                   
                  <input type="hidden" value="search" name="actiontype">
                  <input type="submit" value="Search" name="B1">
                  </p>
                  </form>
                  </center>
                  <br>
                  <%
                  IF action = "search" And search <> "" Then
                  dim mdistid(2000)
                  dim mdistdistance(2000)
                  dim nfound
                  dim findzip

                  nfound=0
                  findzip=mid(search,1,5)
                  dim rszip
                  set rszip=server.CreateObject("Adodb.recordset")
                  rszip.Open "select lat,lon,zipcode from zipdata where zipcode='"+findzip+"'",con
                  srclat=0.00
                  srclon=0.00
                  if not rszip.EOF then
                  srclat=cdbl(rszip("lat"))
                  srclon=cdbl(rszip("lon"))
                  end if
                  dim rsdist
                  set rsdist=server.CreateObject("adodb.recordset")
                  rsdist.Open "select retid,zip,zipcode,lat,lon from ret ,zipdata where mid(zip,1,5)=zipcode ",con
                  while not rsdist.EOF
                  destlat=cdbl(rsdist("lat"))
                  destlon=cdbl(rsdist("lon"))
                  mdistance=calc_distance_lat_lon(srclat,srclon,destlat,destlon)
                  if mdistance <= 50.00 then
                  mdistid(nfound)=rsdist("retid")
                  mdistdistance(nfound)=mdistance
                  nfound=nfound+1
                  end if
                  rsdist.MoveNext()
                  wend
                  if nfound = 0 then
                  s_str = left(search, 3)
                  s_str = trim(s_str)
                  sqltxt ="select * from ret where zip LIKE '" &s_str &"%' ORDER BY Company"
                  set rs=con.Execute(sqltxt)
                  while not rs.eof
                  mdistid(nfound)=rs("retid")
                  mdistdistance(nfound)=nfound
                  nfound=nfound+1
                  rs.movenext()
                  wend
                  end if

                  sort mdistdistance,mdistid,nfound
                  %>
                  <% IF nfound>=1 then %>
                  <div align="center">
                  <center>
                  <table border="1" cellpadding="0" cellspacing="0" width="95%">
                  <tr>
                  <td colspan="8" bgcolor="#000099">
                  <center><font color="white"><b>Retailer Locations</b></font></center>
                  </td>
                  </tr>
                  <tr>
                  <td width="18%" bgcolor="#c0c0c0"><font color="white"><center><b>Company</b></center></font></td>
                  <td width="18%" bgcolor="#c0c0c0"><font color="white"><center><b>Street</b></center></font></td>
                  <td width="13%" bgcolor="#c0c0c0"><font color="white"><center><b>City</b></center></font></td>
                  <td width="8%" bgcolor="#c0c0c0"><font color="white"><center><b>State</b></center></font></td>
                  <td width="8%" bgcolor="#c0c0c0"><font color="white"><center><b>Zip</b></center></font></td>
                  <td width="13%" bgcolor="#c0c0c0"><font color="white"><center><b>Phone</b></center></font></td>
                  <td width="13%" bgcolor="#c0c0c0"><font color="white"><center><b>Fax</b></center></font></td>
                  <td width="8%" bgcolor="#c0c0c0"><font color="white"><center><b>Distance</b></center></font></td>
                  </tr><!-- loop section -->
                  <%
                  for i=0 to nfound-1
                  dim rsfindist
                  sqltxt ="select * from ret where retid=" & mdistid(i)
                  set rsfindist=con.Execute(sqltxt)
                  googlelink=" http://maps.google.com/?saddr="+findzip+"&daddr="+server.URLEncode(rsfindist(3)+", "+rsfindist(4)+", "+rsfindist(5)+" "+rsfindist(6))
                  %>
                  <tr>
                  <td width="18%" bgcolor="#c0c0c0"><font size="1"><% =rsfindist(2) %>
                  <% if len(trim(rsfindist("website"))) > 0 then %>
                  <br><a href="javascript:newwin('<%=rsfindist("website")%>');">Go to Website</a>
                  <% end if%>
                  </font></td>
                  <td width="18%" bgcolor="#c0c0c0"><font size="1"><% =rsfindist(3) %><br><a href="javascript:newwin('<%=googlelink%>');">Google Maps</a></font></td>
                  <td width="13%" bgcolor="#c0c0c0"><font size="1"><% =rsfindist(4) %></font></td>
                  <td width="8%" bgcolor="#c0c0c0"><font size="1"><% =rsfindist(5) %></font></td>
                  <td width="8%" bgcolor="#c0c0c0"><font size="1"><% =rsfindist(6) %></font></td>
                  <td width="13%" bgcolor="#c0c0c0"><font size="1"><% =rsfindist(7) %></font></td>
                  <td width="13%" bgcolor="#c0c0c0"><font size="1"><% =rsfindist(8) %></font></td>
                  <td width="8%" bgcolor="#c0c0c0"><font size="1"><% =formatnumber(mdistdistance(i),2) %></font></td>
                  </tr>
                  <%
                  'rs.MoveNext
                  next
                  %>
                  </table>
                  </center>
                  </div>
                  <% Else %> <div>
                  <center>
                  <table border="0" cellpadding="0" cellspacing="0" width="95%">
                  <tr>
                  <td colspan="7">
                  <center><font color="Red"><b>Retailer Locations Not Found</b></font></center>
                  </td>
                  </tr>
                  </table>
                  </center>
                  </div>
                  <% End if %>
                  <% End if %>
                  • 6. Re: Results from form not coming up
                    Level 7
                    On Wed, 7 Jan 2009 20:20:37 +0000 (UTC), "RMaverick69"
                    <webforumsuser@macromedia.com> wrote:

                    > IF action = "search" And search <> "" Then

                    I haven't done ASP in a really long time, so I'm not the best to address
                    this, but you're using action directly. I seem to recall that you had to
                    access it via the Request.Form array, as in Request.Form("action"). Also,
                    you have no input or prior mentioned variable named search. I'm guessing
                    it should be searchzipcode like your input is named. So the above line
                    would look something like:

                    IF Request.Form("action") = "search" And Request.Form("searchzipcode") <>
                    "" Then

                    Gary
                    • 7. Re: Results from form not coming up
                      Level 7
                      RMaverick69 wrote:
                      > What do you need to test? Here's the actual code for the form:
                      >
                      > <form action="home_depot_new.asp" method="post" name="frmRegister"
                      > id="frmRegister" onsubmit="return validate()">
                      > <p> <font color="#000099" class="txt1">Search
                      > By Zip Code </font>

                      > <input type="text" name="searchzipcode" size="20" />
                      > <input type="hidden" value="search" name="actiontype" />
                      > <input type="submit" value="Search" name="B1" />
                      > </p>
                      > </form>
                      >
                      >
                      > Here's the asp form file:
                      >
                      > <form name="frmRegister" method="POST" action="home_depot_new.asp"
                      > onsubmit="return validate()">
                      >
                      > <p>
                      > <font color="#000099" class="txt1">Search
                      > By Zip Code </font>

                      > <input type="text" name="searchzipcode" size="20">
                      >  
                      > <input type="hidden" value="search" name="actiontype">
                      > <input type="submit" value="Search" name="B1">
                      > </p>
                      > </form>
                      > </center>
                      > <br>
                      > <%
                      > IF action = "search" And search <> "" Then
                      > dim mdistid(2000)
                      > dim mdistdistance(2000)
                      > dim nfound
                      > dim findzip
                      >
                      > nfound=0
                      > findzip=mid(search,1,5)
                      > dim rszip
                      > set rszip=server.CreateObject("Adodb.recordset")
                      > rszip.Open "select lat,lon,zipcode from zipdata where
                      > zipcode='"+findzip+"'",con
                      > srclat=0.00
                      > srclon=0.00
                      > if not rszip.EOF then
                      > srclat=cdbl(rszip("lat"))
                      > srclon=cdbl(rszip("lon"))
                      > end if
                      > dim rsdist
                      > set rsdist=server.CreateObject("adodb.recordset")
                      > rsdist.Open "select retid,zip,zipcode,lat,lon from ret ,zipdata where
                      > mid(zip,1,5)=zipcode ",con

                      Your code is insecure, it will allow SQL injection, something very bad.
                      If the sql user account that you are using isn't locked down then anyone
                      could gain access to your server and it will be compromised. Google SQL
                      injection and see how bad it can be. Its the number 1 way that sites get
                      hacked at the moment.

                      Dooza