PHP gevorderde |
|
<?php
error_reporting(E_ALL);
if($_SERVER['REQUEST_METHOD'] == "POST"){
$text = nl2br($_POST['text']);
echo $text;
echo "<br /><br />";
$aantal = strlen($text)-1;
$bestand = "top.txt";
$openbestand = fopen($bestand, "r");
$gegevens = fread($openbestand, filesize($bestand));
fclose($openbestand);
$gegevens = explode("\n",$gegevens);
echo "<br /><br />Resultaat:<br />";
echo str_replace($gegevens, "hoi", $text);
}else{
?>
<form method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<table><td valign="top">Vul hier uw tekst in: </td>
<td><textarea name="text" cols="40" rows="15"></textarea></td></tr>
<tr><td><input type="submit" value="Verzenden"></td><td> </td>
</table>
</form>
<?php
}
?>
<?php if($_SERVER['REQUEST_METHOD'] == "POST"){ $text = nl2br($_POST['text']); $bestand = "top.txt"; $openbestand = fopen($bestand, "r"); $gegevens = explode("\n",$gegevens); echo "<br /><br />Resultaat:<br />"; }else{ ?> <form method="post" action="<?=$_SERVER['PHP_SELF'];?>"> <table><td valign="top">Vul hier uw tekst in: </td> <td><textarea name="text" cols="40" rows="15"></textarea></td></tr> <tr><td><input type="submit" value="Verzenden"></td><td> </td> </table> </form> <?php } ?>
|