PHP To Create A Dynamic Text Attachment

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Price

    PHP To Create A Dynamic Text Attachment

    Hope someone can help. I am trying to write a php script that will create a
    text file with dynamic fields in it,save the page and then mail it as an
    attachment.

    To be more precise I want the some users details input to the script (name,
    email address etc. ) and then these variables to be inserted into a text
    template
    at various points and then then resulting text file to be saved on the
    server and
    then mailed as an attachment.

    The problem I am having is creating the text document from the script and
    saving it. Would I achive this using a template that is accessed using fopen
    and then using fwrite to insert the variable data at the relevant points or
    is there a different way?

    Thanks in Advance,

    Richard Price




  • Tom Thackrey

    #2
    Re: PHP To Create A Dynamic Text Attachment



    On 29-Sep-2003, "Richard Price" <rprice@directr oute.uk.com> wrote:
    [color=blue]
    > Hope someone can help. I am trying to write a php script that will create
    > a
    > text file with dynamic fields in it,save the page and then mail it as an
    > attachment.
    >
    > To be more precise I want the some users details input to the script
    > (name,
    > email address etc. ) and then these variables to be inserted into a text
    > template
    > at various points and then then resulting text file to be saved on the
    > server and
    > then mailed as an attachment.
    >
    > The problem I am having is creating the text document from the script and
    > saving it. Would I achive this using a template that is accessed using
    > fopen
    > and then using fwrite to insert the variable data at the relevant points
    > or
    > is there a different way?[/color]

    1) Create a template with tags for the data to be replaced. (e.g. Name:
    <<name>>, Phone: <<phone>>)
    2) Open the template and read it into a string with file_get_conten ts (or
    fopen,fread)
    3) Do a $fileString = str_replace('<< name>>',$user_n ame,$fileString ) for
    each tag
    4) Open the text file with fopen(..,'w') and use fwrite to write the updated
    string.


    --
    Tom Thackrey

    Comment

    • Richard Price

      #3
      Re: PHP To Create A Dynamic Text Attachment

      "Tom Thackrey" <tomnr@creati ve-light.com> wrote in message
      news:0HYdb.69$u W4.12986579@new ssvr13.news.pro digy.com...[color=blue]
      >
      >
      > On 29-Sep-2003, "Richard Price" <rprice@directr oute.uk.com> wrote:
      >[color=green]
      > > Hope someone can help. I am trying to write a php script that will[/color][/color]
      create[color=blue][color=green]
      > > a
      > > text file with dynamic fields in it,save the page and then mail it as an
      > > attachment.
      > >
      > > To be more precise I want the some users details input to the script
      > > (name,
      > > email address etc. ) and then these variables to be inserted into a text
      > > template
      > > at various points and then then resulting text file to be saved on the
      > > server and
      > > then mailed as an attachment.
      > >
      > > The problem I am having is creating the text document from the script[/color][/color]
      and[color=blue][color=green]
      > > saving it. Would I achive this using a template that is accessed using
      > > fopen
      > > and then using fwrite to insert the variable data at the relevant points
      > > or
      > > is there a different way?[/color]
      >
      > 1) Create a template with tags for the data to be replaced. (e.g. Name:
      > <<name>>, Phone: <<phone>>)
      > 2) Open the template and read it into a string with file_get_conten ts (or
      > fopen,fread)
      > 3) Do a $fileString = str_replace('<< name>>',$user_n ame,$fileString ) for
      > each tag
      > 4) Open the text file with fopen(..,'w') and use fwrite to write the[/color]
      updated[color=blue]
      > string.
      >
      >
      > --
      > Tom Thackrey
      > www.creative-light.com[/color]


      Worked Fantistically, Thanks.


      Comment

      Working...