hoe kan ik met behulp van php een tekst bestand leeg maken? (via een button)
de buttom moet in gegevens.php komen
dit stuk script is voor het invullen:
(index.php)dit stukje slaat het op in het txt bestand:
(opslaan.php)dit stuk script haalt de gegevens uit het txt bestand:
(gegevens.php)
de buttom moet in gegevens.php komen
dit stuk script is voor het invullen:
(index.php)
Spoiler tonen
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhttm11/DTD/xhtm11-strict.dtd">
<html>
<head>
</head>
<body>
<h3>test 1</h3>
<form action="opslaan.php" method="post">
Uw naam :          <input type="text" name="naam"><br>
Uw achternaam : <input type="text" name="achternaam" width="300" height="400"><br>
Uw e-mail :         <input type="text" name="email"><br><br>
hier uw vraag : <br>
<TEXTAREA NAME="vraag" ROWS="10" COLS="50"></TEXTAREA><br><br>
<input type="submit" value="versturen">
</form>
</body>
</html>(opslaan.php)
Spoiler tonen
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhttm11/DTD/xhtm11-strict.dtd">
<html>
<head>
</head>
<body>
<h3>gegevens verwerkt</h3>
[COLOR= #0000BB]<?php
$naam[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"naam"[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$achternaam[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"achternaam"[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$email[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"email"[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$vraag[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"vraag"[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$data[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"gegevens.txt"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$file[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/fopen"]fopen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$data[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"a"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/fputs"]fputs[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$file[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"<h1>.</h1><br> naam : $naam <br>achternaam : $achternaam<br> e-mail : $email <br> vraag : <br> $vraag <br><br>"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/fclose"]fclose[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$file[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"uw vraag is verstuurd!"[/COLOR][COLOR= #007700];[/COLOR]
?>
</body>
</html >(gegevens.php)
Spoiler tonen
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhttm11/DTD/xhtm11-strict.dtd">
<html>
<head>
</head>
<body>
<h3>gegevens</h3>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"gegevens.txt"[/COLOR][COLOR= #007700]);[/COLOR]
?>
</body>
</html >
