bestand maken

Gestart doorOne2xs11 reacties23 weergaven

12 berichten · pagina 1 van 1

One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
ik heb nu de volgende code:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]inc/functies.php[/COLOR][COLOR= #007700]);[/COLOR]
boven[COLOR= #007700]([/COLOR][COLOR= #DD0000]Admin - Gadgets[/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]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]nieuw[/COLOR][COLOR= #007700]])){[/COLOR]
?>
<form method="post"><br />
Gadget naam:<br />
<input name="gName" type="text" /><br />
Gagdet code:<br />
<textarea name="gCode"></textarea><br />
<input name="submit" type="submit" /><br />
</form>
[COLOR= #0000BB]<?php[/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]
    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gName[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]gadget/[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gName[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000].php[/COLOR][COLOR= #007700]){[/COLOR]
     [URL="http://www.php.net/fopen"]fopen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gName[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #DD0000]a+[/COLOR][COLOR= #007700]);[/COLOR]
     [URL="http://www.php.net/fwrite"]fwrite[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gName[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gCode[/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]<a href="?nieuw">Nieuwe gadget</a>[/COLOR][COLOR= #007700];
}[/COLOR]
onder[COLOR= #007700]();[/COLOR]
?>


en hij moet nu een bestandje aanmaken
maar dit gebeurd niet?
kan iemand helpen?
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je maakt het bestandje niet, je probeert het alleen te openen en er iets in te zetten
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
@luuuk hoe maak ik hem dan?
EDIT:
met x
EDIT2:
fwrite(fopen(gadget/.$_POST[gName]..php,x+), $_POST[gCode]);
werkt pompomEDIT3:
het moest a+ zijn
maar hoe doe ik dat als hij bestaat en hij edit dat hij dan eerst alles delete?
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
A+ = Append, oftewel toevoegen
W+ = Schrijven (en oude dingen dus volgens mij wegdoen).

w Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
w+ Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.

http://nl2.php.net/manual/en/function.fopen.php -> onder mode
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
@Rik
bij W+ krijg ik:
Warning: fopen(gadget/test.php) [function.fopen]: failed to open stream: Success in /home/fmgroup/public_html/linspin.nl/admin_gadget.php on line 16

Warning: fwrite(): supplied argument is not a valid stream resource in /home/fmgroup/public_html/linspin.nl/admin_gadget.php on line 16
EDIT:
ik deed W inplaats van w emo
EDIT:
hoe kan ik de code van de pagina laten zien emo?
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
fopen, fread-> opslaan in een var. En dan met highlight_string() echoën. dan krijg je mooie kleurtjes biggrin
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
en in een textarea?
ik heb dit geprobeerd:

maar dan krijg ik:
Resource id #19

EDIT:

$filename = "gadget/".$row[gName].".php";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
echo $contents;
fclose($handle);
?>
werkt pompom
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
eerst fopen, dan fread ( http://www.php.net/fread )

op deze manier : $contents = fread($handle, filesize($filename));

En dan kan je

echo $contents biggrin
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
is er een manier om in de tekstarea alles in kleurtjes te laten zien biggrin?
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Volgens mij niet cry
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
misschien met javascript etc. biggrin
0
Berichten
431
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Anders gewoon opslaan als phps? Webrequest sturen naar eigen server yummie, dan echoën
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