PHP $fpt make?

Gestart doorAllard19 reacties41 weergaven

20 berichten · pagina 1 van 2

Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,

Ik heb het onderstaande script. Het gaar over het uitvoeren van een bestand. Er is een tekstvak en een submit knop. Als daar tekst in typt komt het te staan in uitvoerpagina.txt. Alleen de tekst die je typt. Maar ik wil dat er ook standaard nog een woord voor komt te staan. Bijvoorbeeld Bericht:. Als je dan hallo in het vak typt. Komt er in uitvoerpagina.txt, Bericht: hallo te staan.

[COLOR= #0000BB]<?php 
 
$s_filename[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]uitvoerpagina.txt[/COLOR][COLOR= #007700];[/COLOR] 
[COLOR= #0000BB]$s_inhoud[/COLOR] [COLOR= #007700]=[/COLOR]  [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$s_filename[/COLOR][COLOR= #007700]);[/COLOR]
 
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]])) {[/COLOR]
  [COLOR= #0000BB]$r_handle[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/fopen"]fopen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$s_filename[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"w+"[/COLOR][COLOR= #007700]);[/COLOR] 
  [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/fwrite"]fwrite[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$r_handle[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]inhoud[/COLOR][COLOR= #007700]])) {[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Schrijven naar bestand mislukt!"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700];
  }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Opdracht uitgevoerd!"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/fclose"]fclose[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$r_handle[/COLOR][COLOR= #007700]);
  }
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]
<html> 
<head> 
<title>Bestand uitlezen</title> 
</head> 
<body> 
<form method="post"> 
<textarea name="inhoud" cols="50" rows="50">[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$s_inhoud[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #DD0000]</textarea> <br />
<input type="submit" name="submit" value="Opslaan" /> 
</form> 
</body> 
</html>[/COLOR][COLOR= #007700];
}[/COLOR]
?>
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
$_POST[inhoud]
vervangen door
Bericht: .$_POST[inhoud]
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oke, bedankt maar kun je me nog even verder helpen?
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb dan nu dit. Maar het woord bericht, moet vervangen worden door $admin[0][name] = "$_POST[gebruikersnaam]";. En Bericht2 moet vervangen worden door $admin[0][pass] = ".$_POST[wachtwoord]"; ?>

Maar hij geeft een error confused
[COLOR= #0000BB]<?php

$s_filename[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]test.php[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$s_inhoud[/COLOR] [COLOR= #007700]=[/COLOR]  [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$s_filename[/COLOR][COLOR= #007700]);[/COLOR]
 
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]])) {[/COLOR]
  [COLOR= #0000BB]$r_handle[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/fopen"]fopen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$s_filename[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"w+"[/COLOR][COLOR= #007700]);[/COLOR]
  [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/fwrite"]fwrite[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$r_handle[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]Bericht [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]Bericht2 [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]])) {[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Schrijven naar bestand mislukt!"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700];
  }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Opdracht uitgevoerd!"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/fclose"]fclose[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$r_handle[/COLOR][COLOR= #007700]);
  }
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]
<html>
<head>
<title>Bestand uitlezen</title>
</head>
<body>
<form method="post">
Gebruikersnaam<input type="text" name="gebruikersnaam" value=""> <br />
Wachwoord<input type="password" name="wachtwoord" value=""> <br />
<input type="submit" name="submit" value="Opslaan" />
</form>
</body>
</html>[/COLOR][COLOR= #007700];
}[/COLOR]
?>
0
Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
welke error geeft hij dan?
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Parse error: syntax error, unexpected T_STRING in /home/domeinsave/domains/domeinsave.one2xs.com/public_html/index2.php on line 8
0
Berichten
1.168
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
doe eens . achter $_POST[wachtwoord]
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
dat moet niet xd
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wat dan?
0
Berichten
1.168
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
of gebruik dubbele haakjes.
0
Berichten
1.601
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
je hebt er HTML bij staan, dit is een PHP dat is het probleem geloof ik
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
nee, als ik php doe is het ook niet goed
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wat staat er in test.php dan?
0
Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bericht AllardBericht2 test

maar als je de nieuwe er onder wilt dan moet je a+ ipv w+
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren