Jump to content

Problem Variables through pages


mstation

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); ?>!
<?
}
?>

 

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.