Skip to main content
Inspiring
May 12, 2009
Answered

I need help showing a users e-mail when they log in. Any help would be much appreciated!

  • May 12, 2009
  • 3 replies
  • 1753 views

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.

This topic has been closed for replies.
Correct answer

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!

3 replies

Mark_A__Boyd
Inspiring
May 15, 2009

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' :-)

May 14, 2009

I just want to ask, is the email stored in same table as with the username?

cwhazzooAuthor
Inspiring
May 14, 2009

Yes it is.

DwFAQ
Participating Frequently
May 18, 2009

Its alright. I know you tried to help. And I still appreciate it.


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!

DwFAQ
Participating Frequently
May 13, 2009

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.

cwhazzooAuthor
Inspiring
May 13, 2009

But how does the Session variable know were to get its information? It only lets me name it not change its properties.

DwFAQ
Participating Frequently
May 13, 2009

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;
?>