![]() |
Writing a PHP and Javascript generated page to a PHP variable...
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 :( |
Re: Writing a PHP and Javascript generated page to a PHP variable...
jonnyblazed@gmail.com 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. jstucklex@attglobal.net ================== |
Re: Writing a PHP and Javascript generated page to a PHP variable...
On 2006-09-03 07:46:32 -0600, Jerry Stuckle <jstucklex@attglobal.net> said:
> jonnyblazed@gmail.com 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. |
Re: Writing a PHP and Javascript generated page to a PHP variable...
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. |
| All times are GMT. The time now is 10:28 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.