Delete stuff in a text pad?

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
shimmyshine
-


Joined: 01 Jul 2006
Posts: 17

PostPosted: Sun Jul 30, 2006 5:32 pm    Post subject: Delete stuff in a text pad? Reply with quote

Ok you guys are great help and allways on the spot with it.. But i am a beginner at PHP just learning now.. So how exactly would I delete stuff in notepad?

? I know I would have to open it ($fp = fopen) then what would I do once inside.. is there a delete all command or something to totaly erase everything in that text pad??

Thanks

ShimmyShine
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sun Jul 30, 2006 5:41 pm    Post subject: Reply with quote

You can use www.php.net/fwrite to find out how to use the command.

There is no delete command if I remember rightly, the best way to do it is to overwrite the file with a blank variable.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
shimmyshine
-


Joined: 01 Jul 2006
Posts: 17

PostPosted: Sun Jul 30, 2006 5:45 pm    Post subject: Reply with quote

For some reason that site doens't work?! It does't load for me..

ShimmyShine
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sun Jul 30, 2006 5:48 pm    Post subject: Reply with quote

shimmyshine wrote:
For some reason that site doens't work?! It does't load for me..

ShimmyShine


It works fine here.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
shimmyshine
-


Joined: 01 Jul 2006
Posts: 17

PostPosted: Sun Jul 30, 2006 5:53 pm    Post subject: Reply with quote

Ok it opened now. But I think this is wrong
Quote:
]<form method=post action="./hitreset/ht1ch1.php"><input type=reset

name=reset value=Reset&nbsp;Hits></form>


Because when I call on it.. it does nothing!

Thanks

ShimmyShine
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sun Jul 30, 2006 5:54 pm    Post subject: Reply with quote

Not sure what you are trying to do there. You have to send a blank variable which will write to the file. Basically the script you normally use to write to the file, but make the variable that gets written blank instead of having a value.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
shimmyshine
-


Joined: 01 Jul 2006
Posts: 17

PostPosted: Sun Jul 30, 2006 5:58 pm    Post subject: Reply with quote

Its a reset button, when its pushed I want it to call on that script.. But it doesn't do it..

ShimmyShine
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sun Jul 30, 2006 6:07 pm    Post subject: Reply with quote

Reset buttons will not call a script. They only reset the values of fields inside a form.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Sun Jul 30, 2006 6:43 pm    Post subject: Reply with quote

This is the script I use in Stream to edit my flat file databases.

Code:
<?php
$fil = "SomeFile.txt";

if ($_POST['spara'] == "ja") {
$write = fopen($fil, "w");
$sparadetta = $_POST['edit'];
fwrite($write, $sparadetta);
fclose($write);
$sparades = true;
}
?>
<a href="stream_block.php"><img src="http://winxtreme.se/content/?text=Reload+db" border=0 /></a><br /><br />
<FORM METHOD='POST' ACTION='<?php echo $_SERVER['PHP_SELF'] ?>'>
<input type="hidden" name="spara" value="ja">
<textarea name='edit' cols='90' rows='31'><?php
$forst = true;
foreach(explode("\n", implode("", file($fil))) as $this_key => $rad) {
if (!$forst) { echo "\n"; } $forst = false;
echo htmlentities($rad);
}
?></textarea><br />
<input TYPE='submit' VALUE='Spara<?php if ($sparades) { echo " (Sparades sist klockan " . date("H:i:s") . ".)"; } ?>'>
</FORM>


This script *should* work. I've edited it to remove the Stream authentication, but I didn't test it.
Back to top View user's profile Send private message
shimmyshine
-


Joined: 01 Jul 2006
Posts: 17

PostPosted: Sun Jul 30, 2006 6:56 pm    Post subject: Reply with quote

Hmm From the looks of your script there cmxflash it shows the IP once used... I was wanting something to where once I click reset it sets that number from w/e to 0.. and I can't seem to figure that out....

ShimmyShine
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sun Jul 30, 2006 6:58 pm    Post subject: Reply with quote

Use a button labelled reset but is a normal button.

The following code will set the text file blank:

Code:
$fp = fopen("file.txt","w");
fwrite($fp, "");
fclose($fp);

_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
shimmyshine
-


Joined: 01 Jul 2006
Posts: 17

PostPosted: Sun Jul 30, 2006 7:06 pm    Post subject: Reply with quote

Ok thanks guys.. Lol im pretty noobish at this.. Thanks again!

So what if I wanted to set a button that would reset ALL of them instead of just one? like how would I add multiple files to that thing you just listed?

Would it be this just duplicated
Quote:
$fp = fopen("file.txt","w");
fwrite($fp, "");
fclose($fp);


ShimmyShine
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group