Try putting this at the top of your doCheckout or the
page name that's not retreiving the user name:

Dim strUserName
strUserName = Request.Cookies("username")

Then your SQL statement should populate with the
username.  

Also, you will need to add code to check for the
existance of the cookie.  The user may delete it or it
may expire and you would be stuck in the same
situation.

So before you do anything, check for a cookie value:

Dim strUserID
strUserID = Request.Cookies("username")
If Len(Trim(strUserID)) = 0 Then
   'Redirect to login page, cookie doesn't exist.
   Response.Redirect("Login.asp")
End If

'*** continue with your existing code...

Mark
--- k4t_9283 <[EMAIL PROTECTED]> wrote:

> No, that's the problem I think!!
> 
> I can't work it out myself! I know that the username
> must be 
> retrieved from somewhere because it works on the
> 'addCart' page but 
> don't know how it is called.
> 
> The only other pages I can think of where it may
> have come from are 
> the 'cart' page and the 'storefuncs' page. When a
> user registers, 
> functiosn are called from the 'storefuncs' page
> which is the page 
> that assigns a cookie. When th euser tries to
> purchase something, 
> the 'cart' page is run and if they are already
> registered, they are 
> taken to the 'addCart' page.
> 
> So, here's the 'cart' page:
> 
>
======================================================================
> ==
> <!-- #INCLUDE FILE="adovbs.inc" -->
> <!-- #INCLUDE FILE="storefuncs.asp" -->
> <%
> ' Get product ID
> productID = TRIM( Request( "pid" ) )
> 
> ' Get Login Information
> username = TRIM( Request( "username" ) )
> password = TRIM( Request( "password" ) )
> register = TRIM( Request( "register" ) )
> error = TRIM( Request( "error" ) )
> 
> 'Open Database Connection
> Set Con = Server.CreateObject( "ADODB.Connection" )
> Con.Open "accessDSN"
> 
> ' Check for New Registration
> IF register <> "" AND error = "" THEN
>   addUser
> END IF
> 
> ' Get User ID
> userID = checkpassword( username, password, Con )
> 
> IF userID > 0 THEN
>    %>
>    <!-- #INCLUDE FILE="addCart.asp" -->
>    <% ELSE %>
>       <!-- #INCLUDE FILE="register.asp" -->
>    <%
> END IF
> %>
> 
>
=====================================================================
> 
> and here's the 'storefuncs' page:
> 
>
=====================================================================
> 
> <%
> '==========================
> '  Common Functions
> '==========================
> FUNCTION fixQuotes( theString )
>   fixQuotes = REPLACE( theString, "'", "''" )
> END FUNCTION
> 
> 
> SUB addCookie( theName, theValue )
>       Response.Cookies( theName ) = theValue
>       Response.Cookies( theName ).Expires = "December 31,
> 2006"
>       Response.Cookies( theName ).Path = "/"
>       Response.Cookies( theName ).Secure = FALSE
> END SUB
> 
> 
> 
> FUNCTION checkpassword( byVal username, byVal
> password, byRef Con )
>   sqlString = "SELECT user_id FROM Users " &_
>     "WHERE user_username='" & username & "' " &_
>     "AND user_password='" & password & "'"
>   SET RS = Con.Execute( sqlString )
>   IF RS.EOF THEN 
>     checkpassword = - 1
>   ELSE
>     checkpassword = RS( "user_id" )
>     addCookie "username", username
>       addCookie "password", password
>   END IF
> END FUNCTION
> 
> 
> FUNCTION SELECTED( firstVal, secondVal )
>   IF cSTR( firstVal ) = cSTR( secondVal ) THEN
>     SELECTED = " SELECTED "
>   ELSE
>     SELECTED = ""
>   END IF
> END FUNCTION
> 
> SUB errorForm( errorMSG, backpage )
>   %>
>   <html>
>   <head><title>Problem</title></head>
>   <body bgcolor="#FFFFC6">
> 
>   <center>  
>   <table width="500" border=1
>     cellpadding=5 cellspacing=0>
>   <tr>
>     <td>
>     <font face="Arial" size="3" color="darkblue"><b>
>     There was a problem with the information you
> entered:
>     </b></font>
>     <font face="Arial" size="2" color="red"><b>
>     <br><%=errorMSG%>
>     </b></font>
>     <br>
>     <form method="post" action="<%=backpage%>">
>     <input name="error" type="hidden" value="1">
>     <% formFields %>
>     <input type="submit" value="Return"> 
>     </form>
>     </td>
>   </tr>
>   </table>
>   </center>
> 
>   </body>
>   </html>
>   <%
>   Response.End
> END SUB
> 
> 
> SUB formFields
>   FOR each item in Request.Form
>   %>
>   <input name="<%=item%>" type="hidden"
>     value="<%=Server.HTMLEncode( Request( item )
> )%>">
>   <%
>   NEXT
> END SUB
> 
> '===========================
> ' Registration Functions
> '===========================
> 
> 
> SUB addUser
>   ' Get Registration Fields
>   newusername = TRIM( Request( "newusername" ) )
>   newpassword = TRIM( Request( "newpassword" ) )
>   title = TRIM( Request( "title" ) )
>   firstname = TRIM( Request( "firstname" ) )
>   surname = TRIM( Request( "surname" ) )
>   gender = TRIM( Request( "gender" ) )
>   email = TRIM( Request( "email" ) )
>   telephone = TRIM( Request( "telephone" ) )
>   street = TRIM( Request( "street" ) )
>   city = TRIM( Request( "city" ) )
>   county = TRIM( Request( "county" ) )
>   postcode = TRIM( Request( "postcode" ) )
>   country = TRIM( Request( "country" ) )
>   cctype = TRIM( Request( "cctype" ) )
>   ccnumber = TRIM( Request( "ccnumber" ) )
>   ccexpires = TRIM( Request( "ccexpires" ) )
>   ccname = TRIM( Request( "ccname" ) )
>   
>   ' Check For Required Fields
>   backpage = Request.ServerVariables( "SCRIPT_NAME"
> )
>   IF newusername = "" THEN
>     errorForm "You must enter a username.", backpage
>   END IF
>   IF newpassword = "" THEN
>     errorForm "You must enter a password.", backpage
>   END IF
>   IF title = "" THEN
>     errorForm "You must enter your title, for
> example, 'Mr'. ", 
> backpage
>   END IF
>   IF firstname = "" THEN
>     errorForm "You must enter your firstname, for
> example, 'Tom'. ", 
> backpage
>   END IF
>   IF surname = "" THEN
>     errorForm "You must enter your surname, for
> example, 'Smith'. ", 
> backpage
>   END IF
> 
=== message truncated ===



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to