Copy link to clipboard
Copied
Hi,
Now that I am able to show someones username after they login using the code below, how in the world do I get a page to show their e-mail. For example when they go to change their e-mail address in the settings in says next to the form "Your current e-mail is set as ..." how do I get it to show?
Username code:
<?php echo $_SESSION['MM_Username']; ?>
Is it at all similar to this?
Thank you for any help.
Okay, if that so then u just need to pull the email variable from the recorset. To make the recorset, go to server behaviour > recordset. On filter field, choose username > session variable > MM_Username. Next, at the panel u may see "Bindings", click it and click at the recorset which u have made before to see all the variables in that recorset(click on plus +). Then u just need to drag that email variable onto your page. It's done! ![]()
Copy link to clipboard
Copied
It is similar in that you use a session variable to display info from database after user has logged in. To show email you must create a session variable for table field of users email address in DB and echo the variable onto the page to display logged in users email address. So create session variable for users email address and echo session variable binding of email address to display on page.
Copy link to clipboard
Copied
But how does the Session variable know were to get its information? It only lets me name it not change its properties.
Copy link to clipboard
Copied
You are talking about setting the binding for the session variable. That does not create the session variable, just the binding for it. Take a look here to see how to create a session variable. Once the session variable is set you can set the binding for it by the session variable name and then place binding onto page to show dynamic info for logged in user. For php to add a session from linked tutorial add code similar to this adding info = to $sessFirstName where appropriate. You can add the session variable onto the page that your users login form is located on. Just add a registered session line and another line to define the newly-registered session variable.
<?php
session_start();
session_register("sessFirstName");
$sessFirstName = $XXXXXXXXXXXX;
?>
Copy link to clipboard
Copied
<?php
session_start();
session_register("sessFirstName");
$sessFirstName = $XXXXXXXXXXXX;
?>
session_register() is deprecated, and won't work on all servers.
The correct way to set session variables is like this:
<?php
session_start();
$_SESSION['firstName'] = 'whatever';
?>
Copy link to clipboard
Copied
Thanks for the clarification David just pasted code from Adobe kb article I linked in earlier post.
Perhaps Adobe should be informed to update their kb article.
Copy link to clipboard
Copied
Ok, now what do I insert in the "whatever" area? The table name or row or something of that sort?
Copy link to clipboard
Copied
what do I insert in the "whatever" area?
Read the article I linked in earlier post.
Insert the variable = to email_address of logged in user from recordset into 'whatever' area.
Copy link to clipboard
Copied
I just want to ask, is the email stored in same table as with the username?
Copy link to clipboard
Copied
Yes it is.
Copy link to clipboard
Copied
Okay, if that so then u just need to pull the email variable from the recorset. To make the recorset, go to server behaviour > recordset. On filter field, choose username > session variable > MM_Username. Next, at the panel u may see "Bindings", click it and click at the recorset which u have made before to see all the variables in that recorset(click on plus +). Then u just need to drag that email variable onto your page. It's done! ![]()
Copy link to clipboard
Copied
Thank you very much for that simple easy to follow working answer. It is very appreciated.
Copy link to clipboard
Copied
I guess I need to get familiar with DW's server behaviors if I want to be able to help in this forum. Nothing in QiQi86's reply seemed simple or easy for me to follow ![]()
I'm glad she was here!
--
Mark A. Boyd
Keep-On-Learnin' 🙂
Copy link to clipboard
Copied
Its alright. I know you tried to help. And I still appreciate it.
Copy link to clipboard
Copied
The method that QiQi86 suggested is effective but if a session variable was created like I was trying to explain earlier then you'd eliminate the need to create a filtered recordset on every page you wanted logged in users info displayed on. You'd simply need to start a session on your page by putting this on first line of php page:
<?php session_start(); ?>
Then echo your session variables on page where you want logged in users info like
<?php echo $_SESSION['logged_in_users_info']; ?>
It's really just the difference between two lines of code on your page to show logged in users info vs. filtered recordset on every page ~ I don't even know how many lines that is!
Copy link to clipboard
Copied
I can't see your login code. Is the user's email address stored in another session variable the same way as MM_Username is? If not, just add this after the line that sets the username. (This assumes your login form has a field named 'email').
$_SESSION['email'] = $_POST['email'];
Then in your other pages,
<?php echo "Your current e-mail is set as {$_SESSION['email']}"?>
--
Mark A. Boyd
Keep-On-Learnin' 🙂
Find more inspiration, events, and resources on the new Adobe Community
Explore Now