mstation Posted October 16, 2009 Share Posted October 16, 2009 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 More sharing options...
dymon Posted October 16, 2009 Share Posted October 16, 2009 You can try to write like this: Congratulazioni <? echo($GLOBALS['nickname']); ?>! Link to comment https://forums.phpfreaks.com/topic/177899-problem-variables-through-pages/#findComment-937993 Share on other sites More sharing options...
mstation Posted October 16, 2009 Author Share Posted October 16, 2009 do i need to do something like global $nickname; $nickname = "new username"; in the mailsender page to be able to use the Congratulazioni <? echo($GLOBALS['nickname']); ?>! ? because i tryed but it doesn't work.. Link to comment https://forums.phpfreaks.com/topic/177899-problem-variables-through-pages/#findComment-938014 Share on other sites More sharing options...
dymon Posted October 16, 2009 Share Posted October 16, 2009 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); ?>! <? } ?> Link to comment https://forums.phpfreaks.com/topic/177899-problem-variables-through-pages/#findComment-938025 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.