Execute PHP file in the background from html page

Reply

Join Date: Jan 2009
Posts: 9
Reputation: Kostas Theof is an unknown quantity at this point 
Solved Threads: 0
Kostas Theof Kostas Theof is offline Offline
Newbie Poster

Re: Execute PHP file in the background from html page

 
0
  #11
Jan 9th, 2009
Thank you ardav and robert_c_guy, I'll check what you suggest as soon as possible.

Is it possible by the way that the output of the php file gets stored in an external log file? (Either by appending new info about warnings, errors, normal output etc, or by replacing each time the existing log file with the new output? You see, this might be helpful sometimes.)

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,267
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 159
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Execute PHP file in the background from html page

 
0
  #12
Jan 9th, 2009
  1. $output = bla blah bla; /* the data output from the background php page. I had to put SOMETHING here, */
  2. $getdate = date( 'd-m-Y, H:i:s' );// Get the date.
  3. $user_ip = $_SERVER['REMOTE_ADDR'];// Get the user IP, just in case.
  4. $referer = getenv("HTTP_REFERER");// Get the refering page. just in case
  5. $file = "./your path to logfile/logfile.csv"; /*define the file as required, csv opens easily in excell or imports to sql if REQ, but is really just a text file.*/
  6. $fp = fopen($file, "a+"); //open the text file for writing.
  7. // Write into the text file.
  8. fputs ($fp, "$getdate, $user_ip, $referer, $output\n"); //see note after $output definition above
  9. fclose($fp);// Close the text file.
create a blank text file logfile.csv (or whatever), this scrap is just an appendage to the existing page, not optimized, just an example, there can be any number of data fields to comprise $output
Last edited by almostbob; Jan 9th, 2009 at 11:15 pm.
Failure is not an option It's included free
If at first you dont succeed, join the club
Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 147
Reputation: mschroeder is on a distinguished road 
Solved Threads: 25
mschroeder mschroeder is offline Offline
Junior Poster

Re: Execute PHP file in the background from html page

 
0
  #13
Jan 10th, 2009
Seems i am a bit late to the game, but your problem definitely lends itself to using AJAX.

and it would be a rather simple solution at that.
Although instead of recommending you learn AJAX from scratch, I'm going to point you to the prototype library http://www.prototypejs.org/ I'm sure you've probably heard of it.

Now,as far as working with prototype, I think the most all encompassing tutorial I have ever seen has to be this one http://www.phpriot.com/series/8-weeks-of-prototype

If you browse through those 8 lessons you'll have a pretty sound understanding of how it all works and comes together.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 867
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 115
ardav's Avatar
ardav ardav is offline Offline
Practically a Posting Shark

Re: Execute PHP file in the background from html page

 
0
  #14
Jan 11th, 2009
Nice tutorial link. I agree if you don't want to leave/return to the html page, use Ajax. I use prototype myself and it's REALLY easy, and I don't even do JS that well.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC