[PHP] pass variable from php script to another php script

2002-01-04 Thread toni baker

I would like to pass the $text variable to the body
of an email message in another php script.  
The code is below:

 -- upload.php -- 
if (!$file=fopen(text.txt, r)) {
echo Could not open file;
  }
  else {
$text=fread($file, 100);
fclose($file);
  }

 -- mail.php -- 
$to = [EMAIL PROTECTED];
$subj = The Subject;
$body=\nBegin .
  \n . quotemeta ($a) .
  \n . quotemeta ($b) .
  \n . quotemeta ($c) .
  \nEnd .
  \n . $text;
$header=From:  . $email .
\r\nReply-To: [EMAIL PROTECTED];

$success = mail ($to, $subj, $body, $header);

I can echo the $text variable to my web form, but
not
to the email body of another php script.  Is this
possible?  How can I get the $text variable to
display in the body of my email message?  Thanks

__
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] pass variable from php script to another php script

2002-01-04 Thread Kevin Stone

It all depends on how you're calling the script.  Obviously these variables
are not system globals.  So if the mail.php script is being accessed
separately from the upload.php script they will not share variables.
However if you include(mail.php); from within upload.php, then it
automaticaly inherets any variables set from within that script.

However if this is not possible, and you're accessing the scripts
separately, you can use session control to pass variables from one script to
another.  You use session_start(); and register the variable,
session_register(text);  Then Launch the mail.php script manualy and you
have access to $text by its short name if register_globals is turned on..
or by $HTTP_SESSION_VARS[text] if register_globals is turned off.

Hope this helps.

-Kevin

- Original Message -
From: toni baker [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, January 04, 2002 12:13 PM
Subject: [PHP] pass variable from php script to another php script


 I would like to pass the $text variable to the body
 of an email message in another php script.
 The code is below:

  -- upload.php -- 
 if (!$file=fopen(text.txt, r)) {
 echo Could not open file;
   }
   else {
 $text=fread($file, 100);
 fclose($file);
   }

  -- mail.php -- 
 $to = [EMAIL PROTECTED];
 $subj = The Subject;
 $body=\nBegin .
   \n . quotemeta ($a) .
   \n . quotemeta ($b) .
   \n . quotemeta ($c) .
   \nEnd .
   \n . $text;
 $header=From:  . $email .
 \r\nReply-To: [EMAIL PROTECTED];

 $success = mail ($to, $subj, $body, $header);

 I can echo the $text variable to my web form, but
 not
 to the email body of another php script.  Is this
 possible?  How can I get the $text variable to
 display in the body of my email message?  Thanks

 __
 Do You Yahoo!?
 Send your FREE holiday greetings online!
 http://greetings.yahoo.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]