Jump to content

Recommended Posts

Hello ppl.. i got this function to send an email through a php webpage:

<?php

//invio email al utente

$content="user_reg.php";

$sender="emailadd"; $username="name";

$subject="subject text";

$alttext="text!";

$destination="destemailadd";

$nickname = "new username";

 

include_once('../class.phpmailer.php');

$mail            = new PHPMailer(); // defaults to using php "mail()"

$body            = $mail->getFile($content);

$body            = eregi_replace("[\]",'',$body);

$mail->From      = $sender;

$mail->FromName  = $username;

$mail->Subject    = $subject;

$mail->AltBody    = $alttext;

 

$mail->MsgHTML($body);

$mail->AddAddress($destination, "nome surname");

 

$_SESSION=array();

if(!$mail->Send()) {

  echo "Mailer Error: " . $mail->ErrorInfo;

} else {

  echo "Message sent!";

}

?>

 

before sending the messages the code reads a content.php file where i have wrote the html which will be the body of my email..

 

the only problem is that i would like to access the $nickname from the content.php and if i write:

Congratulazioni <? echo($nickname); ?>!

 

i dont get the nickname printed inside the email.. any help?

 

Link to comment
https://forums.phpfreaks.com/topic/177899-problem-variables-through-pages/
Share on other sites

In the function getFile () you should write:

 

$nickname = $GLOBALS['nickname'];

 

than print it to be sure it came there.

 

and if in the content.php you call a specific function you do like this:

 

<?
function cong () {
   global $nickname;
?>
   Congratulazioni <? echo($nickname); ?>!
<?
}
?>

 

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.