Forums / General Questions / Fetch user email address from database

Fetch user email address from database

Locked
Results 1 to 7 of 7
This thread is locked. New replies are disabled.
16 Dec 2009, 18:27
#1
hoehnt avatar

hoehnt

New Zenner

Join Date:
Dec 2009
Posts:
13
Plugin Contributions:
0

Fetch user email address from database

Hello,

I have a web page that needs to fetch the current users email address from the database and put it in a form.

How can I do this?
18 Dec 2009, 18:28
#2
hoehnt avatar

hoehnt

New Zenner

Join Date:
Dec 2009
Posts:
13
Plugin Contributions:
0

Re: Fetch user email address from database

I was thinking that since the users login name is his email address I could just capture that login name, set it as a cookie
something like setcookie( "username", $this->customer['email_address']); and then retrieve the cookie into the form on the static page.
Cant figure out how to capture the login name though.

Im not sure how zen cart stores current logged in user status. Does it have the user login in a global variable of some sort i can access it from?
18 Dec 2009, 19:22
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Fetch user email address from database

hoehnt:

Hello,

I have a web page that needs to fetch the current users email address from the database and put it in a form.

How can I do this?

Is this "web page" a Zen Cart page? If so, just use $_SESSION['customers_email_address']
18 Dec 2009, 20:38
#4
hoehnt avatar

hoehnt

New Zenner

Join Date:
Dec 2009
Posts:
13
Plugin Contributions:
0

Re: Fetch user email address from database

DrByte:

Is this "web page" a Zen Cart page? If so, just use $_SESSION['customers_email_address']


Its a static page inserted into my Zen Cart custom template.
18 Dec 2009, 21:51
#5
hoehnt avatar

hoehnt

New Zenner

Join Date:
Dec 2009
Posts:
13
Plugin Contributions:
0

Re: Fetch user email address from database

Shouldnt I be able to do something like:

<INPUT name="useremail" type= "hidden" value="<?=$_SESSION['customers_email_address']?>">
18 Dec 2009, 23:19
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Fetch user email address from database

While I wouldn't recommend using short-tags, yes the concept is correct, as long as you're in a Zen Cart page.

Or, rather than using some 3rd-party tool for collecting form data, why not use Zen Cart's own forms? Or maybe an addon such as the one discussed here: http://www.zen-cart.com/forum/showthread.php?t=4855
21 Dec 2009, 19:45
#7
hoehnt avatar

hoehnt

New Zenner

Join Date:
Dec 2009
Posts:
13
Plugin Contributions:
0

Re: Fetch user email address from database

Tried putting this in tpl_header_default.php and at the top of the static page where it should be loaded (first page after user logs in)
Doesnt appear to do anything.
I am checking the cookies by entering javascript:alert(document.cookie); in my browser address bar.
What zen cart file would you recommend putting it in?

<?php
if ($_SESSION['customer_id'])
{
$var = $_SESSION['customer_id']);
setcookie( "useremail", $var);
}
?>