im trying to run a php script on the onLoad of my page… basically i wanna decrement a number that is stored in a text file… i tried doing this, but it wouldn’t work :frowning:

<script language="JavaScript">
subt = function() {
document.write("$handle = fopen(\"curon.txt\", \"r\");")
document.write("$contents = fgets($handle, 4096);")
document.write("$temp = sprintf(\"%d\", $contents);")
document.write("$handle = fopen(\"curon.txt\", \"w\");")
document.write("fputs($handle, \"$temp\");")
// -->
<body onUnload="subt()">

any help would be appreciated :slight_smile:

I think you would have to write the script in a php page, and onUnload call the page to decrease the number…

oh… haha yeah… didn’t think of that! thanks jubs, will work on that… but would that open a new windows when i load in the php script or something?

can you show me and samples? :slight_smile:

yeah, just to clarify, I am 100% sure that what you are doing wont work. :slight_smile:

You are trying to use a Client-side language to write a server-side script…

You would have to call another page decrease the number and then close the page.

I don’t have any samples, I can show you a code to decrease a number… I know nothing about Javascript…

My first post on that page has a PHP script to increase a number by 1, just change the + to a -

yeah, but I’m not sure on the JAvascript part…

oh okay then, i’ll work that out :slight_smile:

i do have the script to decrement the number already, thanks though


i tried doing this:

<body onUnload="window.location.href = 'unl.php'">

but as i expected it didnt work, althought unl.php works fine when called directly from the browser…

… where’s lost when you need him :stuck_out_tongue: