Jump to content

Archived

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

devofash

function help !!

Recommended Posts

hello ppl got a question........ its quite silly one too *embarassed*

am trying to send an email after a query is updated..... but am getting an error saying :

Warning: mail() [function.mail]: SMTP server response: 554 Error: no valid recipients in C:\Program Files\xampp\htdocs\project\pending_job.php on line 131


here's the code below...... i think i need to pass $email into inform_user() but dont know how to ??

also can anyone suggest a better way of doing this..... it seems to me that i'm doing it the long way !!


[code]
     function pending()
     {
             // some stuff
     }

        function update()
        {
            // update query    
         }

     function inform_user()
     {
      
        mail($email, $subject, $message,
          "From: ORS Webmaster<me@domain.com>\n
          X-Mailer: PHP/" . phpversion());
     }
[/code]

Share this post


Link to post
Share on other sites
It depends, you can use something like this:

[code]function inform_user($email)
{
// code goes here
}[/code]

Or this:

[code]function inform_user()
{
   global $email;
}[/code]

For further information, look for "Variable Scope" in the Manual.

Share this post


Link to post
Share on other sites
Well, you should make pending() return $email... Something like this:

[code]function pending()
{
// do something

return $email;
}

function inform_user()
{
   global $email;
// do something
}

// calling the functions:

$email = pending();
inform_user();[/code]

Share this post


Link to post
Share on other sites
ermmm need it to send email when a record gets updated..... and tht's why perviously i was calling the inform_user() inside the approve function .... how would i do tht ?

Share this post


Link to post
Share on other sites
keep the same format as above,
only put the inform function above the update function,

also make the inform_user function ask for an email variable by calling...

function inform_user($email){ ...
instead of
function inform_user(){...

and then in function update simply call an email variable and pass it by calling inform_user($email);

Share this post


Link to post
Share on other sites
ok so this is what i've done so far .... it sorta works..... here's the code
[code]
<?
     $link = $_GET['link'];
     if($link == approve)
     {
       echo approve();
     }

     function pending()
     {
       // some stuff

        <td> <a href = \"?page=pending_job&link=approve&jobID=$jobID\">
       Approve </a></td>
       return $email;
     }

     function inform_user($email)
     {
       global $email;

          $subject = "blah";
          $message="blah";

       mail($email, $subject, $message,
          "From: ORS Webmaster<me@somedomain.com>\n
           X-Mailer: PHP/" . phpversion());
           echo "Mail has been sent";
     }

     function approve()
     {
       global $email;
           // update record
       if($result)
       {
         echo $email;
         inform_user($email);
       }
     }

     $email = pending();
     inform_user($email);  
?>
[/code]

i want it to send email to a person who's record is updated, after i press the approve link (thts when the record gets updated)

right now it just send an email to the last entry every time page is refreshed.

Share this post


Link to post
Share on other sites
easiest way from wat i can see is parse $email into the link field, so add [b]&email=$email[/b] in the link...
assuming the rows are being parsed thru a 'while' each link shuld have a different email value,

when doing a check for $link==approve,
set $email = $_GET['email']

Share this post


Link to post
Share on other sites
that works :) ......... but what if i want to pass more then one variable ....say for e.g. i want to pass 10 variables.... then it would be a little u know...

for now it works though.... if anyone has a solution plz lemme know :D

Share this post


Link to post
Share on other sites

×

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.