Jump to content

Show eMail on Profile


neex1233

Recommended Posts

Hi, how could I make a PHP script where when you check a select box it will get the user's email from a MySQL database and display it on the user profile? Thanks!

 

This is an idea of what I will use:

 

<?php
$con = mysql_connect("localhost", "Username", "Password") or die('Could not connect: ' . mysql_error());
mysql_select_db("DB_Name", $con);
$username = mysql_real_escape_string($_SESSION["username"]);
$sql = "
   SELECT *
   FROM `users` 
   WHERE username = '$username' 
   LIMIT 0, 30
"; 
$result = mysql_query($sql) or die (mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$email =  $row['email'];
}
echo "$email";
?>

Link to comment
https://forums.phpfreaks.com/topic/164031-show-email-on-profile/
Share on other sites

<?php
session_start();
$con = mysql_connect("localhost", "Username", "Password") or die('Could not connect: ', mysql_error());
mysql_select_db("DB_Name", $con);
$username = mysql_real_escape_string($_SESSION["username"]);
$SQL = 'SELECT `email` FROM `users` WHERE `username` = ', $username, ' LIMIT 0, 30';
$result = mysql_query($SQL) or die('Error in sql: ', mysql_error());+
$args = array();
while($soc = mysql_fetch_assoc($args))	{
$args[] = $soc['email'];
}
echo implode('<br />', $args);
?>

 

Maybe?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.