Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best Approach for profiles? 1

Status
Not open for further replies.

Airpan

Technical User
Jun 14, 2005
172
US
I have successfully completed the administrative side of a project which will allow admins to assign logins to customers. I am now tackling the customer login side of things, and need some input on the best way to approach this. I am not sure how to organize the layout once the customer logs in, due to several things:
1) I need to have the customer login and then be able to view only their profile (resides in custlogins table) and also view their listings (listings being their advertised vehicles, which resides in custinventory table). I cannot seem to write one query which will accomplish both of the above. Question is, can one query accomplish the above? If not, is it possible to have more than one SQL query to accomplish this? I tested a query I wrote and it was able to draw information from both tables but I am not isolating only that user's data.
2)I had thought of using frames to accomplish this, but am a little weary due to not really being a big fan of frames and have not really used them in conjunction with ASP before. Does anyone have any input on frames with ASP? I do realize the potential and drawbacks of frames with regular HTML just didn't know if there was anything additional with ASP to be concerned with?
3) I had also considered possibly assigning customers their usernames to be their CustID's. Thought it might be easier to isolate the data based on their custid's as their usernames. Any potential drawbacks to that?
Thanks.

~E
 
As usual, after I posted the above questions, I think I answered some of my own questions. That being said, I don't think I will use frames. I also think I wrote a query which will perform the above functions. I will post back if there any issues, but I am going to try what I came up with first.

~E
 
My approach would be to build the SQL programatically.

First have a global variable that is set once the customer has logged on and been validated. This variable would be available to all asp pages

Then build you queries e.g.
strSQL = Select Cars From custinventory Where Customer=glbLoggedOnCustomer

This way the Selection would only refer to the records associated with the logged on customer
 
mych,
YOU RAWK. I was just about to post back and say that I built the query...
Code:
"SELECT cust_logins.CustName,cust_logins.Address,cust_logins.City,cust_logins.State,cust_logins.Zip,cust_logins.email,cust_inventory.ListingID FROM cust_logins,cust_inventory WHERE cust_logins.USERNAME='"& username &"'

I was trying to utilize the username to isolate only that user's information, thus it is displaying [incorrectly] that user's information (address and such) with every customers listing number. At any rate, thank you for the sense of direction and will give the global variable a shot.

~E
 
I figured this out with some help from Adobe's help online, and ended up using a session variable to accomplish what I needed. Thanks for the help.

~E
 
Yes session is probably the best way to go.... I tend to develop internal apps where I pull a system variable that list the user name of the user logged onto the workstation that is being used. This is done in the global.asa file and so I can set this to a global variable that is available to all pages of the application.

Mych
 
Mych,
I am running into trouble. I created a session varaible successfully and got it to pass the variable to the next page (after user logs in). However, due to not really using session variables extensively, I need some advice.
I need to be able to use the session variable in a SQL query, so it can use the variable to go the database and pull the information pertaining to that user. Here is the form code:
Code:
<form name="Form" method="post" action="custhome.asp">

<center>
<table border =1>
<tr><td colspan="2">
<%

if blankError<>"" then
Response.Write("<center><font color='red' size='3'>"&blankError&"</font></center>")
end if
%>
</td></tr>
<tr>
<td><Strong><font face="courier new" size="3">Username:</font></strong></td>
<td><input type="text" name="username" size="35"></td>
</tr>
<tr>
<td><Strong><font face="courier new" size="3">Password:</font></strong></td>
<td><input type="password" name="password" size="35"></td>
</tr>
<tr><td colspan="2" align="center"><input type="submit" name="loginButton" value="Login">
<input type="reset" name="reset" value="Clear"></td>
</tr>
</table>
</center>
</form>
On the custhome page, I have the following written for the session variable:
Code:
<%Session("sesUserName")=Request.Form("username")%>
I tried to call it in the SQL query like so:
Code:
SQL = "SELECT * FROM custlogins WHERE [USERNAME] = '"& sesUserName &"' "
Am I using the session variable correctly? Of course, the SQL query doesn't work, but I did get the session variable to write the username to the page, just to make sure it is in fact pulling the username. Any help is appreciated. Thanks again.

~E
 
Airpan,

I think what you will need to do is...

On the page where you are calling the Query set up a variable with the value of the session and then build the query.

Code:
CustomerID = Request.Session("sesUserName")

SQL = "SELECT * FROM custlogins WHERE [USERNAME] = '"& CustomerID &"';"


HTH
Mych
 
Mych,
If I am being dense I apologize ahead of time, I inserted the code on the page in which I created the session variable and the SQL query. I get this error:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'Session'
/aspdevelopment/WasteConn/custhome.asp, line 12

Line 12 is the following code:
Code:
UserID = Request.Session("sesUserName")
I am going for some more coffee, will check back in a bit. :eek:)

~E
 
Its been a long day and I my brain is not in top form...

For session you do not need Request method

just

CustomerID = Session("sesUserName")

SQL = "SELECT * FROM custlogins WHERE [USERNAME] = '"& CustomerID &"';"

and see if that helps.

Mych
 
Mych,
LOL. I hear you about not being up to par... coffee apparently doesn't help much either. Your correction worked... I used a response.write(sql) statement and it worked:
SELECT * FROM cust_logins WHERE [USERNAME]= 'jdoe'
Thanks Mych. Hope your day ends soon and you can relax a bit.

~E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top