Writing a PHP and Javascript generated page to a PHP variable...

Discussion in 'Javascript' started by jonnyblazed@gmail.com, Sep 3, 2006.

  1. Guest

    Okay..... I'm gonna sum up what I want to do cause it will make it
    pretty simple for you guys to understand.

    Here we go:
    I have a form that posts data to a PHP mailer page I have created. When
    it goes to the PHP mailer page it reads some of the data and modifies
    the page accordingly using Javascript (hiding certain divs, etc...). My
    goal, is to take all this data after it has been processed by
    Javascript and send it through my PHP mailer as it is currently
    formatted.

    If it helps any, the track I am on right now involves encapsulating the
    Javascript processed block in a div. I am then trying to take the
    ..innerHTML data from that div and store it in the PHP $message variable
    for my mailer. This won't work because PHP is server side. So, I moved
    on to generate some Javascript code (with PHP) that sends all that
    messy HTML data that its processed through a URL variable to then be
    read by PHP. This doesn't really accomplish what I want as it cuts off
    about a quarter of the way through my data......

    Any ideas??

    One thing I thought of but don't know how to do or whether it's even
    possible is using PHP to view the source of the current page and store
    that as the HTML to be e-mailed. Or, is it possible to do something
    similar to .innerHTML with PHP?


    Well, Thanks in advance everyone! I've been up for the past 4 hours
    trying to figure this out and I rarely post on message boards. You guys
    are my last hope before I'm forced to settle for sending the text
    unformatted and messy :(
    , Sep 3, 2006
    #1
    1. Advertising

  2. wrote:
    > Okay..... I'm gonna sum up what I want to do cause it will make it
    > pretty simple for you guys to understand.
    >
    > Here we go:
    > I have a form that posts data to a PHP mailer page I have created. When
    > it goes to the PHP mailer page it reads some of the data and modifies
    > the page accordingly using Javascript (hiding certain divs, etc...). My
    > goal, is to take all this data after it has been processed by
    > Javascript and send it through my PHP mailer as it is currently
    > formatted.
    >


    And what happens if the user has js disabled?

    > If it helps any, the track I am on right now involves encapsulating the
    > Javascript processed block in a div. I am then trying to take the
    > .innerHTML data from that div and store it in the PHP $message variable
    > for my mailer. This won't work because PHP is server side. So, I moved
    > on to generate some Javascript code (with PHP) that sends all that
    > messy HTML data that its processed through a URL variable to then be
    > read by PHP. This doesn't really accomplish what I want as it cuts off
    > about a quarter of the way through my data......
    >
    > Any ideas??
    >


    Forget the js. Do your work server-side.

    > One thing I thought of but don't know how to do or whether it's even
    > possible is using PHP to view the source of the current page and store
    > that as the HTML to be e-mailed. Or, is it possible to do something
    > similar to .innerHTML with PHP?
    >


    Nope. As you noted, PHP is server side, not client side.

    >
    > Well, Thanks in advance everyone! I've been up for the past 4 hours
    > trying to figure this out and I rarely post on message boards. You guys
    > are my last hope before I'm forced to settle for sending the text
    > unformatted and messy :(
    >


    No, it's not possible to view the source with PHP. However, you
    generated the source - so you should know what it is. And you can
    buffer your output - see ob_start(), etc. - and use it later.

    Not knowing exactly what you're trying to do, it's impossible to say if
    you're on the right track or not. But it seems to be needlessly
    complicated.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.

    ==================
    Jerry Stuckle, Sep 3, 2006
    #2
    1. Advertising

  3. onembk Guest

    On 2006-09-03 07:46:32 -0600, Jerry Stuckle <> said:

    > wrote:
    >> Okay..... I'm gonna sum up what I want to do cause it will make it
    >> pretty simple for you guys to understand.
    >>
    >> Here we go:
    >> I have a form that posts data to a PHP mailer page I have created. When
    >> it goes to the PHP mailer page it reads some of the data and modifies
    >> the page accordingly using Javascript (hiding certain divs, etc...). My
    >> goal, is to take all this data after it has been processed by
    >> Javascript and send it through my PHP mailer as it is currently
    >> formatted.
    >>

    >
    > And what happens if the user has js disabled?
    >
    >> If it helps any, the track I am on right now involves encapsulating the
    >> Javascript processed block in a div. I am then trying to take the
    >> .innerHTML data from that div and store it in the PHP $message variable
    >> for my mailer. This won't work because PHP is server side. So, I moved
    >> on to generate some Javascript code (with PHP) that sends all that
    >> messy HTML data that its processed through a URL variable to then be
    >> read by PHP. This doesn't really accomplish what I want as it cuts off
    >> about a quarter of the way through my data......
    >>
    >> Any ideas??
    >>

    >
    > Forget the js. Do your work server-side.
    >
    >> One thing I thought of but don't know how to do or whether it's even
    >> possible is using PHP to view the source of the current page and store
    >> that as the HTML to be e-mailed. Or, is it possible to do something
    >> similar to .innerHTML with PHP?
    >>

    >
    > Nope. As you noted, PHP is server side, not client side.
    >
    >>
    >> Well, Thanks in advance everyone! I've been up for the past 4 hours
    >> trying to figure this out and I rarely post on message boards. You guys
    >> are my last hope before I'm forced to settle for sending the text
    >> unformatted and messy :(
    >>

    >
    > No, it's not possible to view the source with PHP. However, you
    > generated the source - so you should know what it is. And you can
    > buffer your output - see ob_start(), etc. - and use it later.
    >
    > Not knowing exactly what you're trying to do, it's impossible to say if
    > you're on the right track or not. But it seems to be needlessly
    > complicated.


    I think that part of your problem is that the hidden divs still contain
    data. Rather than hiding them, set their innerHTML to an empty string.
    As far as the rest, you will need to make sure that the page only
    contains the data you want to be part of the email (using JavaScript or
    whatever, though I tend agree with Johnny that you should avoid
    JavaScript unless you have a built in server-side alternative) before
    submitting it to the mailer.
    onembk, Sep 4, 2006
    #3
  4. frothpoker Guest

    you don't say how much of this page is entered by the user and how much
    is 'static' text and how much is generated from a user profile.

    Could you store the bits of text you want in the email and on the web
    page as either database entries or static text and make your script
    simply build the string together from the static text. If you wanted
    to, you could build two strings, one for web page display and one for
    email display inside a function and simply include the email display
    string in the form as a hidden field.

    just a thought.

    Obiron

    > JavaScript unless you have a built in server-side alternative) before
    > submitting it to the mailer.
    frothpoker, Sep 4, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nathan Sokalski
    Replies:
    4
    Views:
    577
    PJ on Development
    Nov 8, 2007
  2. Rajive Narain
    Replies:
    0
    Views:
    1,664
    Rajive Narain
    Sep 18, 2009
  3. mk
    Replies:
    5
    Views:
    142
  4. __
    Replies:
    1
    Views:
    110
    Gregor Kofler
    Oct 2, 2007
  5. Ben Brown
    Replies:
    2
    Views:
    429
Loading...

Share This Page