Hi,

I am trying to display the users email address when they login to there account on there profile page..

I have successfully done this for there username as i use $_COOKIE to display the users name with the DB.

Problem is i am not sure how to do it for email address. Here is my query:

<p><b>Your email address is:</b></p>	
<?php
$query3 = mysql_query("SELECT * FROM userinformation WHERE username = '$username' AND email = 'email'");
while($row = mysql_fetch_array($query3)){
	echo "email";
}	
?>

As you can see i am trying to get the query to understand that i want the email address from the user who username = $username.

But i am sure i am telling it wrong, as i think where i have email = 'email' it is trying to find data in the email field called email.

I am not sure how i get it to understand to get the email address that is assocaited with the username, the username works fine as it gets this from the $_COOKIE as the username and password is stored on users computer as a cookie.

any help much appreciated.

Thanks as always,
genieuk

Assuming you have a field "email" in your table..

<p><b>Your email address is:</b></p>	
<?php
$query3 = mysql_query("SELECT email FROM userinformation WHERE username = '$username'");
while($row = mysql_fetch_array($query3)){
	echo "email address is ". $row[0];
}	
?>

made a change to the sql and the php

Thank you ever so much,

Works great, i see now where i went wrong,

This query is going to become very handy for me. Very useful.

Thank you,
genieuk

Pls try code as follows

<p><b>Your email address is:</b></p>	
<?php
$query3 = mysql_query("SELECT * FROM userinformation WHERE username = '$username' AND email = 'email'");
while($row = mysql_fetch_array($query3)){
	echo $row['email'];
}	
?>

Hi,

I am trying to display the users email address when they login to there account on there profile page..

I have successfully done this for there username as i use $_COOKIE to display the users name with the DB.

Problem is i am not sure how to do it for email address. Here is my query:

<p><b>Your email address is:</b></p>	
<?php
$query3 = mysql_query("SELECT * FROM userinformation WHERE username = '$username' AND email = 'email'");
while($row = mysql_fetch_array($query3)){
	echo "email";
}	
?>

As you can see i am trying to get the query to understand that i want the email address from the user who username = $username.

But i am sure i am telling it wrong, as i think where i have email = 'email' it is trying to find data in the email field called email.

I am not sure how i get it to understand to get the email address that is assocaited with the username, the username works fine as it gets this from the $_COOKIE as the username and password is stored on users computer as a cookie.

any help much appreciated.

Thanks as always,
genieuk

Pls try code as follows

<p><b>Your email address is:</b></p>	
<?php
$query3 = mysql_query("SELECT * FROM userinformation WHERE username = '$username' AND email = 'email'");
while($row = mysql_fetch_array($query3)){
	echo $row['email'];
}	
?>

Hi,

thanks all solved now, but i already did try that and it did not work.

Thanks all for your help.

Regards,
genieuk

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.