Jump to content

php email problem !!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
Flezria

Flezria

    Learning Programmer

  • Members
  • PipPipPip
  • 55 posts
Hey guyse.
I got this php email problem.

I need to Select an email from a database and send a mail to them.

Like this:

$email = $_POST['email'];


$to_email = mysql_query("SELECT email FROM emails WHERE email = '$email'");

$email = mysql_fetch_array($to_email, MYSQL_BOTH);


$to = ;

$subject = 'mail example';

$message = 'example from example with example..';

$headers = 'From: example@example.com


mail($to, $subject, $message, $headers);

but here comes the problem.
How do i get the email out of the database so i can use it in $to variable.
i need it as the email, as a string, so i will send it correctly.

Thanks !! from flezria

#2
brokenbylaw

brokenbylaw

    Learning Programmer

  • Members
  • PipPipPip
  • 62 posts
what does the DB look like?

#3
Flezria

Flezria

    Learning Programmer

  • Members
  • PipPipPip
  • 55 posts
Its a mysql database?

#4
Guest_Jaan_*

Guest_Jaan_*
  • Guests
$email = $_POST['email'];

$sql = "SELECT email FROM emails WHERE email='".$email."'";
$to_email = mysql_query($sql);
$email = mysql_fetch_array($to_email);

$to = $email['email'];
$subject = 'mail example';
$message = 'example from example with example..';
$headers = From: example@example.com

mail($to, $subject, $message, $headers); 

Umm.. it should work..

#5
Flezria

Flezria

    Learning Programmer

  • Members
  • PipPipPip
  • 55 posts
I got it working.
Just replaced the fetch_array with fetch_row ;)