Login | Register | FAQ
Anonymous

Error when clicking 'Enter' button

+ Post a reply

7 posts Page 1 of 1


Error when clicking 'Enter' button

by SteveH » Thu Oct 09, 2014 11:29 pm

Hello

I have a Web page here: http://www.bayingwolf.com/ If I log in with the correct username and ID for a user I know exists in the database (MS Access), I can see the records for that user only - as it should be.

However, if I don't input any username and ID and simply press the 'Enter' button, I am taken to the entire database table (it is now not formatted and unavailable).

What is the best way to prevent this, please?

Thank you.
User avatar

SteveH

  • Posts: 40
  • Joined: Mon Feb 03, 2014 7:32 pm

Re: Error when clicking 'Enter' button

by XainPro » Fri Oct 10, 2014 11:10 am

use logic
if fond record then show otherwise redirect user to homepage and show user that no user found....
User avatar

XainPro

  • Posts: 3933
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: Error when clicking 'Enter' button

by SteveH » Fri Oct 10, 2014 11:50 am

Hello XainPro

That would not work because ALL users are found when the 'Enter' button is pressed.

I would need a script that said something like 'if the 'Enter' button is pressed without the user entering a username and/or password, then nothing happens'.

Thanks again.
User avatar

SteveH

  • Posts: 40
  • Joined: Mon Feb 03, 2014 7:32 pm

Re: Error when clicking 'Enter' button

by XainPro » Mon Oct 13, 2014 6:46 am

then write this in your process file show me your process file
User avatar

XainPro

  • Posts: 3933
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: Error when clicking 'Enter' button

by SteveH » Mon Oct 13, 2014 2:02 pm

This is my process.asp file:

Code: Select all
<%

Dim Connection, Recordset
Dim sSQL, sConnString
Dim fullName, wolfID, telNo, address, email, description, received, action, dispatched

'Create and open Database Connection

sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "E:\Domains\mySite\customers.mdb"

Set connection = Server.CreateObject("ADODB.Connection")

'create recordset object

Set recordset = Server.CreateObject("ADODB.Recordset")

'Open connection

connection.Open sConnString

Dim conn, rs, my_fullName, my_wolfID, my_telNo, my_address, my_email, my_description, my_received, my_action, my_dispatched


' set varaible values from request.form

my_fullName = Replace( Request.Form("fullName"), "'", "''" )
my_wolfID = Replace( Request.Form("wolfID"), "'", "''" )
my_telNo = Replace( Request.Form("telNo"), "'", "''" )
my_address = Replace( Request.Form("address"), "'", "''" )
my_email = Replace( Request.Form("email"), "'", "''" )
my_description = Replace( Request.Form("description"), "'", "''" )

my_received = Request.Form("received")

my_action = Replace( Request.Form("action"), "'", "''" )
my_dispatched = Replace( Request.Form("dispatched"), "'", "''" )

'build insert statement

sSQL="INSERT INTO tblWolf " &_
"(fullName, wolfID, telNo, address, email, description, received, [action], dispatched)" &_
" VALUES ('" & my_fullName & "', '" & my_wolfID & "', '" & my_telNo & "', '" & my_address & "', '" & my_email & "', '" & my_description & "', '" & my_received & "', '" & my_action & "', '" & my_dispatched & "')"

' insert record

connection.Execute sSQL

'write on screen

Response.write "<div align='center'><p class='font'>The record has been added.</p></div>"

'build select SQL

sSQL="SELECT TOP 20 ID, fullName, wolfID, telNo, address, email, description, received, action, dispatched FROM tblWolf ORDER BY ID DESC"

'open recordset

recordset.Open sSQL,connection

response.write "<table class='myTable'>"

%>

<tr class="headerRow">
                <td>ID</td>
      <td>Full Name</td>
      <td>Wolf ID</td>
      <td>Tel No</td>
                <td>Address</td>
      <td>Email</td>
      <td>Description</td>
      <td>Received</td>
                <td>Action</td>
      <td>Dispatched</td>
    </tr>

<%
'write data from recordset to table

If Recordset.EOF Then
    Response.Write "<tr><td>No records returned.</td></tr>"
Else
    Do While Not recordset.EOF

        Response.Write "<tr><td>" & recordset("ID") & "</td>"
        Response.Write "<td>" & recordset("fullName") & "</td>"
        Response.Write "<td>" & recordset("wolfID") & "</td>"
        Response.Write "<td>" & recordset("telNo") & "</td>"
        Response.Write "<td>" & recordset("address") & "</td>"
        Response.Write "<td>" & recordset("email") & "</td>"
        Response.Write "<td>" & recordset("description") & "</td>"
        Response.Write "<td>" & recordset("received") & "</td>"
        Response.Write "<td>" & recordset("action") & "</td>"
        Response.Write "<td>" & recordset("dispatched") & "</td></tr>"
       
        ' move to next record
       
        Recordset.MoveNext
       Loop

'close recordset

Recordset.close
response.write "</table>"
End If
%>

<%

'close connection

connection.Close

'destroy recordset object

set Recordset = nothing

'destroy connection object

Set connection = Nothing
%>


Many thanks for your time.
User avatar

SteveH

  • Posts: 40
  • Joined: Mon Feb 03, 2014 7:32 pm

Re: Error when clicking 'Enter' button

by XainPro » Tue Oct 14, 2014 5:31 am

your code is not suitable for login process this process is saving data into database and then showing top 20 users
you must re-code the process file where the select statement is like

select * from users where user_id = formFiled and password = formField

read this tutorial maybe this would help you
http://support.microsoft.com/kb/301464
User avatar

XainPro

  • Posts: 3933
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: Error when clicking 'Enter' button

by SteveH » Tue Oct 14, 2014 9:27 pm

Thanks for your reply and the link.

The code works, but I could not get this part to work:

Code: Select all
<%
Validated = "OK"
if Request.Cookies("ValidUser") <> Validated then
'Construct the URL for the current page.
    dim s
    s = "http://"
    s = s & Request.ServerVariables("HTTP_HOST")
    s = s & Request.ServerVariables("URL")
    if Request.QueryString.Count > 0 THEN
   s = s & "?" & Request.QueryString
    end if
    'Redirect unauthorized users to the logon page.
    Response.Redirect "Logon.asp?from=" &Server.URLEncode(s)
End if
%>


If I type in: s = "http://"

I get a internal server error (file not found).
User avatar

SteveH

  • Posts: 40
  • Joined: Mon Feb 03, 2014 7:32 pm


+ Post a reply

Page 1 of 1