Jump to content

function help !!


devofash

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<[email protected]>\n
          X-Mailer: PHP/" . phpversion());
     }
[/code]
Link to comment
https://forums.phpfreaks.com/topic/7662-function-help/
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);
Link to comment
https://forums.phpfreaks.com/topic/7662-function-help/#findComment-28114
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<[email protected]>\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.
Link to comment
https://forums.phpfreaks.com/topic/7662-function-help/#findComment-28167
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']
Link to comment
https://forums.phpfreaks.com/topic/7662-function-help/#findComment-28252
Share on other sites

Archived

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

×
×
  • Create New...

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.