View previous topic :: View next topic |
Author |
Message |
shimmyshine -
Joined: 01 Jul 2006 Posts: 17
|
Posted: Sun Jul 30, 2006 5:32 pm Post subject: Delete stuff in a text pad? |
|
|
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 |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Sun Jul 30, 2006 5:41 pm Post subject: |
|
|
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 |
|
|
shimmyshine -
Joined: 01 Jul 2006 Posts: 17
|
Posted: Sun Jul 30, 2006 5:45 pm Post subject: |
|
|
For some reason that site doens't work?! It does't load for me..
ShimmyShine |
|
Back to top |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Sun Jul 30, 2006 5:48 pm Post subject: |
|
|
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 |
|
|
shimmyshine -
Joined: 01 Jul 2006 Posts: 17
|
Posted: Sun Jul 30, 2006 5:53 pm Post subject: |
|
|
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 Hits></form> |
Because when I call on it.. it does nothing!
Thanks
ShimmyShine |
|
Back to top |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Sun Jul 30, 2006 5:54 pm Post subject: |
|
|
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 |
|
|
shimmyshine -
Joined: 01 Jul 2006 Posts: 17
|
Posted: Sun Jul 30, 2006 5:58 pm Post subject: |
|
|
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 |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Sun Jul 30, 2006 6:07 pm Post subject: |
|
|
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 |
|
|
cmxflash -
Joined: 11 Dec 2004 Posts: 872
|
Posted: Sun Jul 30, 2006 6:43 pm Post subject: |
|
|
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 |
|
|
shimmyshine -
Joined: 01 Jul 2006 Posts: 17
|
Posted: Sun Jul 30, 2006 6:56 pm Post subject: |
|
|
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 |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Sun Jul 30, 2006 6:58 pm Post subject: |
|
|
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 |
|
|
shimmyshine -
Joined: 01 Jul 2006 Posts: 17
|
Posted: Sun Jul 30, 2006 7:06 pm Post subject: |
|
|
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 |
|
|
|