Jump to content

SQL Query PHP, Display Email


Matt01

Recommended Posts

I am new to this sql / php thing and need some help on a query.

 

I got a database with a bunch of values in, ID, Username, Email, Password, IP,... and so on.

 

I need some simple script that will display the email address on the webpage of the user logged on.

 

Im not sure howto do this and cant seem to find any examples on the net.

 

Can anyone help?

Link to comment
Share on other sites

Got an example maq?

 

I just want an example to display an email address from a field linking the ID to whos logged on

 

ID Username Password  Email                        IP

1  Matt      Let Me In  Matt@needshelp.com  127.0.01

2  Maq        Help Me    Maq@helpmeplz.com  XXX.XXX.XXX.XXX

 

Just a simple script to display the value of the email address depending whos logged on

 

I learn from examples, if I cant find an example then i cant really learn anything.

Link to comment
Share on other sites

I found this script on the net, it works but it displays all the email address' in the field Email because ID isnt included in the code.

 

$result = mysql_query("SELECT * FROM Users");

while($row = mysql_fetch_array($result))

  {

echo "" . $row['Email'] . "";

  }

 

I need to somehow include a ID so it only displays the email address of the user logged on and not all the email address'.

 

Can someone help me please, I know your prob thinking amg what a n00b but really this script is doing my head in.

I know theres someone out there who can do this in like 10secs so please post since im getting really annoyed with server errors!!!

 

I tried to change the code to add ID but im still prob not doing the right thing.

 

<?php

$id = $_GET['id'];

$result = mysql_query("SELECT * FROM Users WHERE Email = '$id' LIMIT 1");

while($row = mysql_fetch_array($result))

  {

echo "" . $row['Email'] . "";

  }

?>

Link to comment
Share on other sites

Of course this: $id = $_GET['id']; isn't going to work...  Why would you compare an id to an email?

 

You need to assign a session ID and compare that with the ID's in your DB.  I'm sure there's plenty of tutorials for this but here's what your query portion would look like:

 

$id = $_SESSION['id'];
$result = mysql_query("SELECT * FROM Users WHERE Email = " . $id . "");
while($row = mysql_fetch_array($result))
{
     echo $row['Email'];
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.