includes and php

The attached page has an include:

$messagetext = include 'email-content.php';

I am trying to send this in an input message box but it will not show up
I also do not want this include showing ojn thye page - just to be sent  as content

At present It is just sent as $messagetext;
send-email_b_mailer.php
doctorbillTechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marco GasiFreelancerCommented:
First, you should use this syntax:

<left>Contact email body:&nbsp;</em><input name="message" type="text" id="message" value="<?php  echo $messagetext; ?>" /></left>

Open in new window


But you have also to use a different syntax to 'include the file:

$messagetext = file_get_contents(ìemail-content.php');

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
$messagetext = include 'email-content.php';
No, you can't 'include' to a variable.  The 'included' content becomes directly part of the code.  Marco's suggestion of 'file_get_contents' can bring a file into a variable.

http://php.net/manual/en/function.include.php
0
doctorbillTechAuthor Commented:
This is my page
It displays the include but the include does not get sent in the message box
It appears outside of the message box

<?php
$messagetext = file_get_contents('email-content.php');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Send Email</title>
</head>

<body>
<?php require_once('../../../TickTock_int/menu_mailer.html'); ?>


<br />
<br />
<div align="center">
<div style="width:350px;" align="left">
<center><?php require_once('logo_header.php'); ?></center>

<form id="form1" name="form1" method="post" action="../../../phpmailertest/email.php">
 
  <left>Contact email address:&nbsp;</em><input name="email" type="text" id="email" /></left><br />
 <left>Contact email body:&nbsp;</em><input name="message" type="text" id="message" value="<?php  echo $messagetext; ?>" /></left>
  <br />
  <br />
 
  <left><em>CC:&nbsp;</em><input name="cc" type="text" id="cc" /></left>
  <br />
  <br />
  <input type="submit" name="Submit" value="Submit" style="float:right;"/>
</form></div>
</div>
</body>
</html>
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

doctorbillTechAuthor Commented:
ok - now it is working:
Is there a way to hide the include data from view in the text area (and maybe put a message there instead), but still send the include data
------------
<?php
$messagetext = file_get_contents('email-content.php');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Send Email</title>
</head>

<body>
<?php require_once('../../../TickTock_int/menu_mailer.html'); ?>


<br />
<br />
<div align="center">
<div style="width:350px;" align="left">
<center><?php require_once('logo_header.php'); ?></center>

<form id="form1" name="form1" method="post" action="../../../phpmailertest/email.php">
 
  <left>Contact email address:&nbsp;</em><input name="email" type="text" id="email" /></left><br />
 <left>Contact email body:&nbsp;</em><textarea name="message" rows="1" cols="75" id="message" value="<?php  echo $messagetext; ?>"></textarea></left>
  <br />
  <br />
 
  <left><em>CC:&nbsp;</em><input name="cc" type="text" id="cc" /></left>
  <br />
  <br />
<br />
  <input type="submit" name="Submit" value="Submit" style="float:right;"/>
</form></div>
</div>
</body>
</html>
0
Dave BaldwinFixer of ProblemsCommented:
Put the external data in a <input type="hidden"> element.  What is a <left> tag?  I don't find it in a list of HTML elements.

<input name="hidden" type="hidden" value="<?php  echo $messagetext; ?>" />

Open in new window

0
doctorbillTechAuthor Commented:
this does not appear to hide the info:

Contact email body:&nbsp;</em><textarea name="message" type="hidden" rows="10" cols="75" id="message" value="<?php  echo $messagetext; ?>"></textarea>
0
Dave BaldwinFixer of ProblemsCommented:
I'm not surprised since you didn't copy the example I gave you.  There is no type="hidden" for 'textarea's, just for 'inputs's.  The other alternative is to use CSS to hide the 'textarea'.  See the examples here: http://www.w3schools.com/css/css_display_visibility.asp
0
doctorbillTechAuthor Commented:
the css did it

Thank you all for your input - as usual very fast and very accurate
Answers are always very concise
0
doctorbillTechAuthor Commented:
resolved
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.