p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: Re: How to let users change there own details


Message #1 by "Sandra" <salau@p...> on Mon, 10 Jun 2002 21:33:02
You could store the user id and check it against a table of known id's in 
a database...

or pass it over as a hidden value in a form
or session variables
and then go from Clint's suggestion, which is the best idea. Since it 
would autopopulate - less chance of any anomalies. 

HTH,
Sandra

Message #2 by "CLINTON PARSLEY" <cparsley@m...> on Thu, 06 Jun 2002 08:01:05 -0700
I'm assuming each user as a unique record which contains all of their 
information. I'm also assuming the user is logged in before they have the 
oppurtunity to edit their information. Once these two conditions are met, 
you could create a page which populates a form (more than likely the very 
same form the user used to fill in their details) with their record. Since 
they are logged in you could store the unique userID just about anywhere ( 
session variable, cookie....) create a means ( a link that brings them to a 
myInfo.asp page perhaps ). Once on the page, grab the userID, using this 
userID create your sql statement to retrieve the users record, and populate 
the form.

hth,
Clint

----Original Message Follows----
From: dont worry <aspmailbox@y...>
Reply-To: "ASP Databases" <asp_databases@p...>
To: "ASP Databases" <asp_databases@p...>
Subject: [asp_databases] Re: How to let users change there own details
Date: Thu, 6 Jun 2002 06:11:20 -0700 (PDT)

I dont think you want to use this .Find thing.  A
better way would be to generate a random code number
when a user logs in, attach it to the query string and
then just grab from querystring on each page and check
against the database.  This is the way the big players
do it.
Do a search for log in systems.

--- ryan <cartman_203@h...> wrote:
 > I am making a user login script that connects to a
 > database. with this i
 > want to users be able to edit there own details like
 > address and phone
 > number etc. this script here
 >
 > objRec.Find "Username = " & Session("Username")
 > won't work but
 > objRec.Find "Username = " & Request.Form("Username")
 > will work but i can't
 > use it since the user could enter any username so i
 > want it to use the
 > session variable.
 >
 > is there anyother way to use the session variable
 > with find?
 >
 > What the below script should do (if it worked) is
 > bring up a form with the
 > current data from the database in the text fields,
 > then you can change
 > them. If i don't put the objRec.Find ....... then it
 > display the first
 > record in the database and changes it.
 >
 >
 > <%
 >
 > dim objConn
 > dim objRec
 >
 > Set objConn 
 > Server.CreateObject("ADODB.Connection")
 > Set objRec = Server.CreateObject("ADODB.Recordset")
 >
 > objConn.Open "DSN=users"
 > objRec.Open "users", objConn, adOpenStatic,
 > adLockOptimistic, adCmdTable
 >
 > 	objRec.Find "Username = " & Session("Username")
 >
 > 	Response.write "<form action 
 > 'display_details.asp' method 
 > post><br>"
 > 	' Primary Key
 > 	Response.write "<input type = 'hidden' name 
 > 'userID' value = '"
 > & objRec.Fields("UserID") & "'><p>"
 >
 > 	Response.write "Address: "
 > 	Response.write "<input type = 'text' name 
 > 'address' value = '" &
 > objRec.Fields("Address") & "'><p>"
 >
 > 	Response.write "Phone Number: "
 > 	Response.write "<input type = 'text' name 
 > 'phone_number' value
 > = '" & objRec.Fields("Phone_number") & "'><p>"
 >
 >
 > 	Response.write "<input type = 'submit' value 
 > 'modify'><p>"
 >
 > objRec.Close
 > objConn.Close
 >
 > Set objRec = Nothing
 > Set objConn = Nothing
 > %>
 >


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

Message #3 by dont worry <aspmailbox@y...> on Thu, 6 Jun 2002 06:11:20 -0700 (PDT)
I dont think you want to use this .Find thing.  A
better way would be to generate a random code number
when a user logs in, attach it to the query string and
then just grab from querystring on each page and check
against the database.  This is the way the big players
do it.
Do a search for log in systems.

--- ryan <cartman_203@h...> wrote:
> I am making a user login script that connects to a
> database. with this i 
> want to users be able to edit there own details like
> address and phone 
> number etc. this script here 
> 
> objRec.Find "Username = " & Session("Username")
> won't work but
> objRec.Find "Username = " & Request.Form("Username")
> will work but i can't 
> use it since the user could enter any username so i
> want it to use the 
> session variable.
> 
> is there anyother way to use the session variable
> with find?
> 
> What the below script should do (if it worked) is
> bring up a form with the 
> current data from the database in the text fields,
> then you can change 
> them. If i don't put the objRec.Find ....... then it
> display the first 
> record in the database and changes it.
> 
> 
> <%
> 
> dim objConn
> dim objRec
> 
> Set objConn 
> Server.CreateObject("ADODB.Connection")
> Set objRec = Server.CreateObject("ADODB.Recordset")
> 
> objConn.Open "DSN=users"
> objRec.Open "users", objConn, adOpenStatic,
> adLockOptimistic, adCmdTable
> 
> 	objRec.Find "Username = " & Session("Username")
> 
> 	Response.write "<form action 
> 'display_details.asp' method = 
> post><br>"
> 	' Primary Key
> 	Response.write "<input type = 'hidden' name 
> 'userID' value = '" 
> & objRec.Fields("UserID") & "'><p>"
> 
> 	Response.write "Address: "
> 	Response.write "<input type = 'text' name 
> 'address' value = '" & 
> objRec.Fields("Address") & "'><p>"
> 
> 	Response.write "Phone Number: "
> 	Response.write "<input type = 'text' name 
> 'phone_number' value 
> = '" & objRec.Fields("Phone_number") & "'><p>"
> 
> 
> 	Response.write "<input type = 'submit' value 
> 'modify'><p>"
> 
> objRec.Close
> objConn.Close
> 
> Set objRec = Nothing
> Set objConn = Nothing
> %>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
Message #4 by "ryan" <cartman_203@h...> on Wed, 5 Jun 2002 20:00:29
I am making a user login script that connects to a database. with this i 
want to users be able to edit there own details like address and phone 
number etc. this script here 

objRec.Find "Username = " & Session("Username") won't work but
objRec.Find "Username = " & Request.Form("Username") will work but i can't 
use it since the user could enter any username so i want it to use the 
session variable.

is there anyother way to use the session variable with find?

What the below script should do (if it worked) is bring up a form with the 
current data from the database in the text fields, then you can change 
them. If i don't put the objRec.Find ....... then it display the first 
record in the database and changes it.


<%

dim objConn
dim objRec

Set objConn = Server.CreateObject("ADODB.Connection")
Set objRec = Server.CreateObject("ADODB.Recordset")

objConn.Open "DSN=users"
objRec.Open "users", objConn, adOpenStatic, adLockOptimistic, adCmdTable

	objRec.Find "Username = " & Session("Username")

	Response.write "<form action = 'display_details.asp' method = 
post><br>"
	' Primary Key
	Response.write "<input type = 'hidden' name = 'userID' value = '" 
& objRec.Fields("UserID") & "'><p>"

	Response.write "Address: "
	Response.write "<input type = 'text' name = 'address' value = '" & 
objRec.Fields("Address") & "'><p>"

	Response.write "Phone Number: "
	Response.write "<input type = 'text' name = 'phone_number' value 
= '" & objRec.Fields("Phone_number") & "'><p>"


	Response.write "<input type = 'submit' value = 'modify'><p>"

objRec.Close
objConn.Close

Set objRec = Nothing
Set objConn = Nothing
%>


  Return to Index