Jump to content

Recommended Posts

Hello Freaks!!

 

I have a question that has been boggling my mind for sometime, but never looked into it. Basically what I have been doing is trying to send HTML info through a variable, but everytime I do it, I have to select the HTML and do a FIND: " & REPLACE WITH: \" in Dreamweaver.

 

It was fun in the beginning, but now it seems to be a pain, and wish to just do a simple

 

include("../htmlinfo.php");

 

But when I do that of course, the variables that I am trying to pass through do not get executed. I am basically doing this for HTML Email and stuff.

 

 

So to recap, I want to turn this:

 

<?php

$content = "<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
<title>Untitled Document</title>
</head>

<body>
<table width=\"654\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td>CONTACT</td>
    <td> </td>
  </tr>
  <tr>
    <td align=\"right\">Name:</td>
    <td> </td>
  </tr>
  <tr>
    <td align=\"right\">Number:</td>
    <td> </td>
  </tr>
  <tr>
    <td align=\"right\">Email:</td>
    <td> </td>
  </tr>
  <tr>
    <td align=\"right\">City:</td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
  </tr>
</table>
</body>
</html>";
?>

 

TO THIS:

 

<?php

$content = include("../htmlform.inc.php");

?>

 

The reason why I want to make this simple is because if I change something in the HTML, I have to repaste the code, and do the FIND and REPLACE method again. Just does not seem too efficient.

 

Any suggestions?

 

 

Thank you!

Olie

 

Link to comment
https://forums.phpfreaks.com/topic/173578-html-in-php/
Share on other sites

just storing the value in a variable won't echo it out. What does your include page look like? if it looks like the first php you posted, don't assign the variable, just write the code, and when you include it the code will be executed.

 

Well basically I am just using the $content variable to send out a HTML email, which is why I am using the FIND & REPLACE method. I can't seem to find another way to pass it through to email to everyone.

 

So I would use it as:

 

<?php
mail("olie@whatever.com", $subject, $content);
?>

 

But whenever I use the

 

<?php

$content = include("../html.inc.php");

?>

 

The only thing that shows up in the email is the number 1

 

 

I should also let you know that I am setting this up because variable data is being sent from MySql to input into the HTML portion... Like "Hello Mike!... yadda yadda yadda..."

Link to comment
https://forums.phpfreaks.com/topic/173578-html-in-php/#findComment-914973
Share on other sites

That is because the include() -function does not return the file contents, it returns 1 if the include was succesful. You must use other file reading functions to read the file in to variable and then use this variable in the email. For example file_get_contents() could do it(?).

Link to comment
https://forums.phpfreaks.com/topic/173578-html-in-php/#findComment-914978
Share on other sites

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.