Page 1 of 1

If update send mail??

Posted: Mon May 14, 2012 5:32 am
by krisma
Hallo guys!!

I have this script

Code: Select all

<?php
$name = mysql_real_escape_string($_REQUEST['name']);
$link = mysql_real_escape_string($_REQUEST['link']); 
$filename = mysql_real_escape_string($_REQUEST['filename']);
if(empty($name) || empty($link) || empty($filename))exit; 

mysql_connect('localhost','root','');
@mysql_select_db('1') or die( "Unable to select database");

if (!mysql_query("INSERT INTO `1`.`files` (`name`,`link`,`filename`) VALUES ('$name','$link','$filename');"))
  {
  echo 'Fail!';
  exit;
  }
  else
  {
  echo "Succesfuly added!";  
  }
mysql_close();

?>
works fine when they send me link to

mydomain.com/script.php?name=1&link=2&filename=3

and database updates fine , but the idea is

That each name is owned by a group and every group has a different email adresse , how can automatically
send email at the time someone send a link to my adress (mydomain.com/script.php?name=1&link=2&filename=3)

with few words i want to notify the owner of the group (name) for the link and filename values


Thats the story
Thanks!!!

Re: If update send mail??

Posted: Mon May 14, 2012 6:02 am
by social_experiment
If the email address of each group is stored it is a matter of retrieving it from the database and then sending the email as soon as an update occurs.

Re: If update send mail??

Posted: Wed May 16, 2012 2:15 am
by krisma
i dont know how to do it :/

Re: If update send mail??

Posted: Wed May 16, 2012 3:07 am
by social_experiment
do you store the email addresses?

Re: If update send mail??

Posted: Wed May 16, 2012 3:14 am
by krisma
Emails will be stored to different sql table

where id 1 is email@email1.com
id 2 email2@email.com

etc etc ,, and somehow script must match "name" values with emails table id and send email to specific email adresse

i can add bellow else
{
$email_report = "File: $filename <br /> Link: $link .... so on";
mail($email_to, "Someone downloaded your file", $email_report);

but how can i retrieve from $name value the email to use it for $email_to

Re: If update send mail??

Posted: Wed May 16, 2012 5:05 pm
by social_experiment
krisma wrote:etc etc ,, and somehow script must match "name" values with emails table id and send email to specific email adresse
Is there a foreign key that binds the two tables together? Also, could you explain how the process works, (or correct me if i am incorrect) - When a record is inserted into the database, (as per the pasted code) an email is sent out to the group owning the specific name ($name in this instance)