943,806 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 7512
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jan 9th, 2009
0

Re: Execute PHP file in the background from html page

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kostas Theof is offline Offline
9 posts
since Jan 2009
Jan 9th, 2009
0

Re: Execute PHP file in the background from html page

php Syntax (Toggle Plain Text)
  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.
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Jan 10th, 2009
0

Re: Execute PHP file in the background from html page

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.
Sponsor
Reputation Points: 265
Solved Threads: 126
Practically a Master Poster
mschroeder is offline Offline
624 posts
since Jul 2008
Jan 11th, 2009
0

Re: Execute PHP file in the background from html page

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.
Sponsor
Featured Poster
Reputation Points: 1048
Solved Threads: 947
Sarcastic Poster
ardav is offline Offline
6,680 posts
since Oct 2006
Jul 5th, 2011
-1
Re: Execute PHP file in the background from html page
very easy just put this in header

<script language="php" src='yourfile.php'></script>


YAHYA AL-SALMANI
SAUDI ARABIA
Reputation Points: 10
Solved Threads: 0
Newbie Poster
yahya al salman is offline Offline
1 posts
since Jul 2011

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Using Prepared Statement - Help!
Next Thread in PHP Forum Timeline: php mod_rewrite help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC