添加/清除命令到html表单

I have some code for a type of note making thing:

<h1>Notes About the rebellion:</h1>
<form action="index.php" method='post'>
Subject:<br><textarea name='textblock'></textarea><br>
Note:<br><textarea name='textblock2'></textarea><br>
<input type='submit' value='Add text'>
</form>
<iframe src="text.txt"></iframe>
<?php

// Open the text file
$f = fopen("text.txt", "a");

// Write text
fwrite($f, $_POST["textblock"] . ":" . PHP_EOL); 
fwrite($f, $_POST["textblock2"] . PHP_EOL . "
"); 
//fwrite($f, $_POST["textblock"] . "
");
// Close the text file
fclose($f);

// Open file for reading, and read the line
$f = fopen("text.txt", "r");

// Read text
echo fgets($f); 
fclose($f);

?>

Basically, I want when I type "/clear" in the second html form input, and submit it, the text file "text.txt" will be either deleted or cleared.

This will do what exactly you want.

<h1>Notes About the rebellion:</h1>
<form action="index.php" method='post'>
Subject:<br><textarea name='textblock'></textarea><br>
Note:<br><textarea name='textblock2'></textarea><br>
<input type='submit' value='Add text'>
</form>
<iframe src="text.txt"></iframe>
<?php

// Open the text file
$f = fopen("text.txt", "a");

// Write text
fwrite($f, $_POST["textblock"] . ":" . PHP_EOL); 
fwrite($f, $_POST["textblock2"] . PHP_EOL . "
"); 
//fwrite($f, $_POST["textblock"] . "
");
// Close the text file
if($_POST["textblock2"]=="/clear"){
  fclose($f);                       //for clearing text in file
  $f = fopen( 'filelist.txt', 'w' ); //for clearing text in file
  fclose($f);              
  delete("text.php");  //for deleting file
}
else{
  fclose($f);
}
// Open file for reading, and read the line
$f = fopen("text.txt", "r");

// Read text
echo fgets($f); 
fclose($f);

?>