Jump to content

including php vairables in an email


blink359

Recommended Posts

How do i include a php variable inside the body of my email i've tried a number of things and have had no success here is my code a the moment

<? 
    
FunCtion gEtRAnDomString($lEngth = 4) {

  $vAliDChArACtErs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
   $vAliDChArNumBEr = strlEn($vAliDChArACtErs);

   $rEsult = "";

   For ($i = 0; $i < $lEngth; $i++) {
       $inDEx = mt_rAnD(0, $vAliDChArNumBEr - 1);
       $rEsult .= $vAliDChArACtErs[$inDEx];
    }

   rEturn $rEsult;
}
FunCtion gEtRAnDomString1($lEngth = 6) {

  $vAliDChArACtErs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
   $vAliDChArNumBEr = strlEn($vAliDChArACtErs);

   $rEsult = "";

   For ($i = 0; $i < $lEngth; $i++) {
       $inDEx = mt_rAnD(0, $vAliDChArNumBEr - 1);
       $rEsult .= $vAliDChArACtErs[$inDEx];
    }

   rEturn $rEsult;
}
FunCtion gEtRAnDomString2($lEngth = 4) {

  $vAliDChArACtErs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
   $vAliDChArNumBEr = strlEn($vAliDChArACtErs);

   $rEsult = "";

   For ($i = 0; $i < $lEngth; $i++) {
       $inDEx = mt_rAnD(0, $vAliDChArNumBEr - 1);
       $rEsult .= $vAliDChArACtErs[$inDEx];
    }

   rEturn $rEsult;
}
FunCtion gEtRAnDomString3($lEngth = 6) {

  $vAliDChArACtErs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
   $vAliDChArNumBEr = strlEn($vAliDChArACtErs);

   $rEsult = "";

   For ($i = 0; $i < $lEngth; $i++) {
       $inDEx = mt_rAnD(0, $vAliDChArNumBEr - 1);
       $rEsult .= $vAliDChArACtErs[$inDEx];
    }

   rEturn $rEsult;
}
FunCtion gEtRAnDomString4($lEngth = 4) {

  $vAliDChArACtErs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
   $vAliDChArNumBEr = strlEn($vAliDChArACtErs);

   $rEsult = "";

   For ($i = 0; $i < $lEngth; $i++) {
       $inDEx = mt_rAnD(0, $vAliDChArNumBEr - 1);
       $rEsult .= $vAliDChArACtErs[$inDEx];
    }

   rEturn $rEsult;
}
$code = "
gEtRAnDomString()
-
gEtRAnDomString1()
-
gEtRAnDomString2()
-
gEtRAnDomString3()
-
gEtRAnDomString4()
";

//change this to your email. 
    $to = "n**********"; 
    $from = "na*******y_19*******co.uk"; 
    $subject = "Code"; 
    $message = "Your order code is: $code ";
   $headers .= "From: $from"; 
    mail($to, $subject, $message, $headers); 
    echo "Message has been sent....!"; 
?> 


If anyone can help it will be great

 

Thanks,

 

Blink359

Link to comment
https://forums.phpfreaks.com/topic/222078-including-php-vairables-in-an-email/
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.