Page 1 of 1

Having the link when modification

Posted: 2019-04-02 10:21
by pasbonte
Hello
I use this code to send a mel when a record is changed.

Code: Select all

foreach($data as $field => $value){
        $messageData .= "$field: $value \n";
    } 
    sendmail(array(
        'to' => '[email protected]',
        'name' => 'Recipient Name',
         
        'subject' => 'Sortie Modifiée',
         
        'message' => "Attention modification de la sortie: {$memberInfo['username']}: \n\n" . $messageData
    ));

But instead of the whole message I'd like to just have the link to click

MERCI !!!!

Re: Having the link when modification

Posted: 2019-04-02 10:37
by jsetzer
The link should look like this:

Code: Select all

<a href="http://www.yourserver.com/path/tablename_view.php?SelectedID=12345">Click here</a>
You need to replace servername, path, tablename and ID by the appropriate values.

You can try this:

Code: Select all

$server = 'YOURSERVERNAME'; // eg. www.my-great-appgini-website.com
$path = 'YOUR-APP-PATH'; // eg. myapp
$tn = 'TABLENAME'; // name of your table
$text = 'Click here to open the record in your browser';

// dont's change the following lines -----------
$id = $data['selectedID'];
$href = "http://{$server}/{$path}/{$tn}_view.php?SelectedID={$id}";
$link = "<a href=\"{$href}\">{$text}</a>";
// ----------------------------------------------------

sendmail(array(
  'to' => '[email protected]',
  'name' => 'Recipient Name',
  'subject' => 'Sortie Modifiée',
  'message' => "Attention modification de la sortie: {$memberInfo['username']}: \n\n" . $link
));
I hope there is no typo.

Regards,
Jan

Re: Having the link when modification

Posted: 2019-04-02 13:31
by pasbonte
I tried:

Code: Select all

function SORTIES_after_update($data, $memberInfo, &$args){
    foreach($data as $field => $value){
        $messageData .= "$field: $value \n";
		// dont's change the following lines -----------
$id = $data['selectedID'];
$href = "http://{$server}/{$path}/{$tn}_view.php?SelectedID={$id}";
$link = "<a href=\"{$href}\">{$text}</a>";
// ----------------------------------------------------
		
    } 
    sendmail(array(
        'to' => '[email protected]',
        'name' => 'Recipient Name',
         
        'subject' => 'Sortie Modifiée',
         
        'message' => "Attention modification de la sortie: {$memberInfo['username']}: \n\n" . $link
    ));

//'message' => "Attention modification de la sortie: {$memberInfo['username']}: \n\n" . $messageData . $link

));
	
	
		return TRUE;
	}
and i have:
Attention modification de la sortie: admin:

Re: Having the link when modification

Posted: 2019-04-02 14:04
by jsetzer
You must not put the code on the for-loop

Re: Having the link when modification

Posted: 2019-04-02 14:05
by jsetzer
You have forgotten $text variable

Re: Having the link when modification

Posted: 2019-04-02 14:06
by jsetzer
I guess you have also forgotten $server, $path and $tn