+ Reply to Thread
Results 1 to 9 of 9

Thread: try to attach <?php tags, plese help.

  1. #1
    coacalli is offline x10Hosting Member coacalli is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    10

    Post try to attach <?php tags, plese help.

    Greetings, this is my problem.

    I'm far from a versed coder on php but try to do my best with wht i have.

    this is what i have.

    i've a mailer on php that sends a bunch of variables to the user depending on the request.

    the mail that u get has a html, css styled page that contains the info the user requested and, u know, promotional ads, institucional head banner and stuff... a predefined format.

    the thing is i tend to change my mind a lot about looks and it seems to me to be quite a dragg to make my format and then put a lot of backslashes every coutation mark on the code so i'm able to import the format on the body of the mail. (am i getting my self clear? english is... just... so... tree twisted witches watches each switch of tree swiss swatch watches)

    on the end i finish with something like:

    $varHeaders = "something";
    $varBody_content = "something else";
    $varSubject = "other something";
    $varTo = "thepoorbastardi'msendingthemail";

    $varBody_format = "lots of html code with the \ every single time a \" is on the text"
    ."and somewhere on the text such \"variables\" as <span class=\"content\" >$varBody_content</span>"
    ." or maybe <div id=\"to\">$varTo</div> "
    ."You get the idea"
    ;


    So, my question after all this is: How can i get a html file that has php vars stated as $something as the value of another variable with out have the need of translate it into php?

    on other words, is there a way to:

    $varNeed_htmlpage = something('myhtml.html');

    or something that can do the \ for me.


    thanks a lot.
    Hello earth, Greetings from the Third World!

  2. #2
    VPmase's Avatar
    VPmase is offline x10 Elder VPmase is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Dixon, IL, USA
    Posts
    914

    Re: try to attach <?php tags, plese help.

    Are you talking about includes?
    http://us3.php.net/manual/en/function.include.php

  3. #3
    sarvar's Avatar
    sarvar is offline x10Hosting Member sarvar is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    82

    Re: try to attach <?php tags, plese help.

    If you don't want to put backslashes often, just use single quotes around the html. For example like this.

    PHP Code:
    $variable '<div id="test">This is a html without the need of backslashes</div>'
    CLICK HERE to Thank Me.
    (You must be logged in into forums.)

  4. #4
    akkudreamz's Avatar
    akkudreamz is offline x10 Sophmore akkudreamz is an unknown quantity at this point
    Join Date
    Jan 2009
    Location
    Jaipur, Rajasthan, India
    Posts
    183

    Re: try to attach <?php tags, plese help.

    use the PHP adslashes() function
    Ref:W3schools

    About the other part if you wana put the static content part into another file you can do it and include it into your PHP script just like mentioned above by VPmase

    hope this helps


    If you need to remove those slashes somewhere in your code you can use the stripslashes function
    Last edited by akkudreamz; 02-10-2009 at 09:07 PM.
    Be safety conscious. 80% of people are caused by accidents.
    My Weblog

  5. #5
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: try to attach <?php tags, plese help.

    This is something I am working on now.

    If you are explaining what I think you are explaining, here is an example php code and variables blended with html that should help. (This was part of a form - obviously)

    PHP Code:
    <?php 
    $fromname 
    stripslashes($_POST['fromname']);
    $fromemail stripslashes($_POST['fromemail']);
    $toemail stripslashes($_POST['toemail']);
        
    $headers  'MIME-Version: 1.0' "\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\n";
    $headers .= "Content-Transfer-Encoding: 7bit\n"
    $headers .= 'From: Sender <'.$fromemail.'>' "\n";
    $headers .= 'Reply-To: '.$fromemail."\n";
    $headers .= 'X-Mailers: PHP /'.phpversion() . "\n";
    $subject $_POST['subject'];
    $message $_POST['msg'];

        
        
        if (@
    mail($toemail,stripslashes($subject),stripslashes($message),stripslashes($headers)))
        {
            echo (
    '<p>Your message has been sent.</p>');
        }
        else
        {
            echo (
    '<p>Your message has failed to send.</p>');
        }
    As you can see, the whole section is in php so you have to use 's to contain/ break out of the relevant code. The same principal can be used in subject and message.

    i.e.
    PHP Code:
    <?php
    $message 
    'this is a test page to establish if you can put in a '.$variable.' or not.';

  6. #6
    coacalli is offline x10Hosting Member coacalli is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    10

    Re: try to attach <?php tags, plese help.

    Thanks for all your answers and i can asure you that i have tryed all your points, but unfortunatelly i'm afraid i'm not making my self clear about what i want.

    when we use the include(something) method the page printos out the content of the included file, on the other hand if we use it directly as a variable value ir returns a numeric value that tells us if the file was loaded or not.

    on the other hand, using the single quotation marks on the html is an interesting solution to the backslashing problem, but it still makes mandatory to turn the page into php code instead of plain html. So it solves just a tiny part of the problem.


    i'll try to be a bit more clear about what i try to do.

    We all know how to make a mailing system, no secrets there, but when it comes to make a format that fits the client specifications.. that's why I want to solve this puzzle.

    I've found my self that on PHP you can make almost everything a variable, even variable names can be variable for what i know.

    so, what i want is to make the content of a HTML page the value of a variable, no print it out or include it as part of the output but only include the contents as part of the prosses.

    when ever i use the include(something) method it displays the content of my HTML file, and there's no use for it on a page that only processes information.

    so, maybe you could say i'm alzy, or too obssesed with this point, but i don't want to have to write an html page, then turn it into php every single time i have to make a change on it (maybe i am lazy or even crazy).

    PLease, can any body help?
    Hello earth, Greetings from the Third World!

  7. #7
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: try to attach <?php tags, plese help.

    you can use heredoc to define your html variables

    EDIT:

    Oh so you want a templating system!!!

    I've created one, if you want. It's very simple, and it's easy to use. PM if you are interested.
    Last edited by xav0989; 02-14-2009 at 12:34 PM. Reason: OK
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  8. #8
    coacalli is offline x10Hosting Member coacalli is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    10

    Re: try to attach <?php tags, plese help.

    Interesting aproach xav, but maybe i'm not that versed on the use of heredoc, correct me (pleasE!) if i'm wrong, but doesn't it woks only to printout large amounts of text with out the need of scaping characters?

    if this is the case, is not working for me cos what i need is the code on my HTML be the value for a variable, thus i can change that file when ever i want and not having to change the code on the mailer.
    Hello earth, Greetings from the Third World!

  9. #9
    kbjradmin's Avatar
    kbjradmin is offline x10 Elder kbjradmin is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    Washington State, USA
    Posts
    512

    Re: try to attach <?php tags, plese help.

    PHP Code:
    <?php
    $code 
    fopen(filename"r");
    echo 
    $code;
    ?>
    i think that's right, check it first.

+ Reply to Thread

Similar Threads

  1. How to create ~ Meta Tags
    By lair360 in forum Tutorials
    Replies: 1
    Last Post: 01-22-2009, 09:32 AM
  2. html tags - help anyone?
    By ispital in forum Programming Help
    Replies: 15
    Last Post: 05-02-2008, 06:51 AM
  3. PHP remove html/other uncessary tags? - need help
    By a-a-a in forum Scripts & 3rd Party Apps
    Replies: 8
    Last Post: 10-30-2007, 07:12 PM
  4. Little help here with those tags
    By thinhso in forum Free Hosting
    Replies: 0
    Last Post: 06-02-2006, 02:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers