If update send mail??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
krisma
Forum Newbie
Posts: 3
Joined: Mon May 14, 2012 5:31 am

If update send mail??

Post 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!!!
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: If update send mail??

Post 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.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
krisma
Forum Newbie
Posts: 3
Joined: Mon May 14, 2012 5:31 am

Re: If update send mail??

Post by krisma »

i dont know how to do it :/
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: If update send mail??

Post by social_experiment »

do you store the email addresses?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
krisma
Forum Newbie
Posts: 3
Joined: Mon May 14, 2012 5:31 am

Re: If update send mail??

Post 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
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: If update send mail??

Post 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)
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply