Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

creating login page - direct users to a unique file based on unique id?

New Here ,
Jul 27, 2009 Jul 27, 2009

Hello - I am in the process of creating a login page that will direct users to a unique page based on their unique id.  I would normally go to Server Behaviors>User Auth>Log In User, but that gives me the option of browsing only one file for all usernames and that's not what I need.  So basically, if the user logs in with the Caterpillars username, it takes them directly to the Caterpillars page and if they log in with the Butterflies username, it takes them to the Butterflies page (yes, it's a preschool with goofy classroom names!).  If it matters, I'm using MySql and the page is .php.  I tried to upload the php, but it gave me an error "the content type of this attachment is not allowed" - not sure what that's all about - sorry.

Thanks in advance!!

TOPICS
Server side applications
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 27, 2009 Jul 27, 2009

Heya,

You said this:

that gives me the option of browsing only one file for all usernames and that's not what I need.

And actually one dynamic file is all you need...

Create a log in user server behavior on the login page like you would usually do and in redirect page for successful login have it go to something like success.php Then you can create a filtered recordset on the success.php page filtered where table column for id = session variable set for logged in users id. Then the page wil display info dynamically based on the logged in users id. To learn how to create a session variable look here http://kb2.adobe.com/cps/165/tn_16563.html your users ID may already be created as a session variable MM_UserGroup so try that first in your filtered recordset.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 27, 2009 Jul 27, 2009

Thanks!  I thought it made sense until now.  I have the username session on the success.php page and the login works great, but I still don't understand how I tell it do display a different page for each username (i.e. caterpillars username takes you to the caterpillars page, butterflies username takes you to the butterflies page, etc).  It's got to be some sort of "if/then" thing...right?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 27, 2009 Jul 27, 2009

Please read again:

create a filtered recordset on the success.php page filtered where table column for id = session variable set for logged in users id. Then the page wil display info dynamically based on the logged in users id.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 27, 2009 Jul 27, 2009

Me again - I've read that many times and I thought I understood what you were saying, but maybe not?  On success.php I have created a filtered recordset (username = session variable MM_UserGroup). I then add the session variable <?php echo $_SESSION['sessUsername']; ?> to the same page.  Am I misssing something?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 27, 2009 Jul 27, 2009

I said:

create a filtered recordset on the success.php page filtered where table column for id = session variable set for logged in users id.

You did:

On success.php I have created a filtered recordset (username = session variable MM_UserGroup)

Is the table column for ID "username"? Do yourself a favor and test the recordset when creating it by using the little test button. I think if you want to filter username then it would be where Session variable = MM_Username - if you want to filter ID then the session variable = MM_UserGroup. It all depends on what your session variables are set as and what column on your DB table you are filtereing the session variable against.

Just remember to test the recordset while in the recordset window to see if it's setup properly. For testing a recordset that involves a session variable you will be asked to add some data for the variable in order to test. So if you were testing a filtered recordset where username = session variable MM_Username then test it will ask you to enter a username to test the recordset. Enter a username in your database like user_someone to show user_someone's info in the filtered recordset results.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 27, 2009 Jul 27, 2009

I do have a serial ID column, however the column in the db for the usernames is called "username".  I've tried it both ways - username and usergroup.  I have used the test button several times - each time I change something I test it and it shows the appropriate record in the db.  Right now I have filtered recordset username = session variable MM_Username and the variable session is Session.MM_Username.  I can login, but it gives me the success.php page and it's blank.  I'm just not understanding where it's supposed to get the correct page for each username...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 27, 2009 Jul 27, 2009
I test it and it shows the appropriate record in the db.

If it shows the record in the test of the recordset then to display the info on the page echo the field you'd like displayed by dragging from the bindings window to the page where you'd like it displayed. It wouldn't be <?php echo $_SESSION['sessUsername']; ?> like you mentioned earlier it would be

<?php echo $row_recordset_name['database_table_field']; ?>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 27, 2009 Jul 27, 2009

Yep, I do have the recordset on there now.  I really appreciate your patience.  I've always just had to point all logins to one file and it made complete sense.  This one has thrown me for a loop.  I always work in split view so I'm looking at it and...the code has all the php goodness in it, but what should the design view end of things look like?  Maybe that will get me to the problem faster...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 27, 2009 Jul 27, 2009

>I always work in split view so I'm looking at it and...the code has all the php

>goodness in it, but what should the design view end of things look like?

I'm still not sure you understand what DwFAQ is telling you so I will try. DwFAQ is recommending that you use a single page that everyone is redirected to upon a successful login. That page will have different content for each user, as the content will be pulled from a database. So everyone is redirected to success.php, but one user might see butterflies while another sees caterpillars. Is this your understanding?

This has the advantage of only having to maintain a single user page, as the different content is stored in the database. If this is not possible for some reason, then you will need to learn some more hand coding as redirection to different pages is not handled in the server behaviors. One method would be to store the redirect page/path in the database with the user info, and then use that in your redirect statement.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 27, 2009 Jul 27, 2009

The good news is that we are on the same page as far as that goes.  I was trying to do the latter - store the path for each individual file (catepillars.html, butterflies.html, etc) in the database with the login info.  My problem is that I can't get it to direct to that page in the code.  My understanding is that I have to tell it in within this code <?php echo $row_MM_Username['login']; ?> that if username is caterpillars then they go directly to caterpillars.html...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 27, 2009 Jul 27, 2009
I was trying to do the latter - store the path for each individual file (catepillars.html, butterflies.html, etc) in the database with the login info. My problem is that I can't get it to direct to that page in the code.  My understanding is that I have to tell it in within this code <?php echo $row_MM_Username['login']; ?> that if username is caterpillars then they go directly to caterpillars.html...

For your desire you don't need extra database fields, recordsets, session variables or anything else if you want to direct username to a static username.html file

Instead use a dynamic META redirect in <head> of success.php page based on session variable for Username and append .html to the username.

<META http-equiv="refresh" content="0;URL=http://example.com/<?php echo $SESSION['MM_Username']; ?>.html">

You could add the show if users is logged in server behavior to success.php and wrap the meta redirect in it so that if the user is logged in then you are redirected to username.html or just add a restrict access SB so that you can not visit success.php (and be redirected to username.html) unless you are logged in.

Does that solve your problem?

It may have been easier to explain if your original inquiry mentioned that you wanted logged in users to go to a static .html page based on their username like username.html (sighs). FWIW I would still follow my original recommendation of using one dynamic file to display different users info on one page because as mentioned you only have to maintain one file vs. multiple static files.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 27, 2009 Jul 27, 2009
LATEST

Sorry for the sighs.  Appreciate the help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines