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.

Correct answer
May 15, 2009

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!

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.

cwhazzooAuthor
Inspiring
May 13, 2009

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

?>


Ok, now what do I insert in the "whatever" area? The table name or row or something of that sort?