CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   Check a user and display there email address??? (http://www.codingforums.com/showthread.php?t=284983)

mike92 12-29-2012 02:21 AM

Check a user and display there email address???
 
Hi I am really stuck on a piece of code that checks the users username and then displays there email address ?
Any ideas?

Sorry I mean I want to display the email inside the code to forward an email to the correct username
for example user01@mydomain.com receives an email from user02@mydomain.com, I want the script to take the user01 and search the database for the forwarding email and then send it??

Redcoder 12-29-2012 08:22 AM

No...there can be no ideas until you give us something tangible to think on. We may be awesome but we are not God.

Like give us a piece of code that you are stuck on. Or tell us to help you with the logic and give you ideas then.

Clawed 12-29-2012 02:49 PM

Quote:

Originally Posted by mike92 (Post 1302834)
Hi I am really stuck on a piece of code that checks the users username and then displays there email address ?
Any ideas?

We can't do nothing without seeing code, but here's what i think you need:
PHP Code:


$username 
"Santa";
$query mysql_query("SELECT email FROM users WHERE username = '" $username "' LIMIT 1");
$row mysql_fetch_assoc($query);

echo 
$row['email']; 


mike92 12-29-2012 04:29 PM

The Code
 
I have a pipe script which pipes the email's to PHP.
I want to forward the email to the correct username
for example user01@mydomain.com receives an email from user02@mydomain.com, I want the script to take the user01 and search the database for the forwarding email and then send it??

I am really new to this bellow is a very poor attempt which I know I have all wrong..........


PHP Code:

// from = there email
$from  "email@mydomain.com";
// to = there username 
$to ="$username";
// me= machine host name
$me    php_uname('n');
// host= smtp server 
$host  'localhost';
// msg= the original email message
$msg=$email;
// forward is the email address i want to forward to  
$forward=$data=mysql_query("SELECT * FROM users where $username='email'")
or die (
mysql_error ());
$info=mysql_fetch_array($data);
{
echo 
".$info['email'];
}
require_once '../../SMTP.php';
if(!($smtp = new Net_SMTP($host, 25, $me)))
  die("
sending mail failed to initializen");
if(PEAR::isError($smtp->connect(30)))
  die("
sending mail failed to connectn");
if(PEAR::isError($smtp->mailFrom($from)))
  die("
sending mail failed to set from address [$from]n");
if(PEAR::isError($smtp->rcptTo($to)))
  die("
sending mail failed to set RCPT TO [$forward]n");
if(PEAR::isError($smtp->data($msg)))
  die("
sending mail failed to set data and sendingn");
$smtp->disconnect(); 


Any help would be great :)


All times are GMT +1. The time now is 12:50 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.