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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.