Simpel Gastenboek

Gestart doorThijns16 reacties57 weergaven

17 berichten · pagina 1 van 2

Thijns

Lid · Topicstarter

Berichten
457
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Beste One2xsers,
Ik ben mezelf mbv cursussen en tuturials php aan het leren en probeer nu zelf een gastenboek in elkar te zetten simpel mbv. een .txt bestandje.
Nu heb k deze codegemaakt in een bestand genaamd test4.php:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<font size="5"><b>Gastenboek</b></font><br>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<HR SIZE="1" align=left width=400 NOSHADE>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"gastenboek.txt"[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
<form action="test4.php" method="get">         
Naam:
<input type="text" name="name">
<br>
Text:
<input type="text" name="text">
<br>
<input type="submit" value="Verstuur" name="submit">
<input type="Reset" name="Reset"> </form>
<?[/COLOR][COLOR= #007700];[/COLOR]


[COLOR= #0000BB]$name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"$_GET[name]"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$text[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"$_GET[text]"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$file[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/fopen"]fopen[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"gastenboek.txt"[/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]"
<table border=0 width=400 cellpadding=0 cellspacing=0>
<tr><td width=100><b>Schrijver:</b></td><td>$name</td></tr>
<tr><td width=100><b>Datum:</b></td><td>$date</td></tr>
<tr><td colspan=2><b>Text:</b></td></tr>
<tr><td colspan=2>$text</td></tr>
<tr><td colspan=2><HR SIZE="[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #DD0000]" NOSHADE></td></tr>
</table>
"[/COLOR]
[COLOR= #007700]);[/COLOR]
?>


Maar nu krijg ik de volgende error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:xampphtdocs	est4.php on line 19


Wat doe ik fout?
0
Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<font size="5"><b>Gastenboek</b></font><br>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<HR SIZE="1" align=left width=400 NOSHADE>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"gastenboek.txt"[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
<form action="test4.php" method="get">         
Naam:
<input type="text" name="name">
<br>
Text:
<input type="text" name="text">
<br>
<input type="submit" value="Verstuur" name="submit">
<input type="Reset" name="Reset"> </form>[/COLOR][COLOR= #007700];[/COLOR] 


[COLOR= #0000BB]$name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"$_GET[name]"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$text[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"$_GET[text]"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$file[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/fopen"]fopen[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"gastenboek.txt"[/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]"
<table border=0 width=400 cellpadding=0 cellspacing=0>
<tr><td width=100><b>Schrijver:</b></td><td>$name</td></tr>
<tr><td width=100><b>Datum:</b></td><td>$date</td></tr>
<tr><td colspan=2><b>Text:</b></td></tr>
<tr><td colspan=2>$text</td></tr>
<tr><td colspan=2><HR SIZE="[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #DD0000]" NOSHADE></td></tr>
</table>
"[/COLOR]
[COLOR= #007700]);[/COLOR]
?>
0
Berichten
450
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nickje dat kan niet wink
want dit kan helemaal niet

$name="$_GET[name]";
$text="$_GET[text]";
0
Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee idd zie ik nu pas yummie
Hhhm...

Het is " en door elkaar.
0
Thijns

Lid · Topicstarter

Berichten
457
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt voor de reacties tot nu toe, maar hoe moet het dan? confused
0
Berichten
515
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Probeer het eens zo :

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<font size="5"><b>Gastenboek</b></font><br>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<HR SIZE="1" align=left width=400 NOSHADE>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"gastenboek.txt"[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
<form action="test4.php" method="get">         
Naam:
<input type="text" name="name">
<br>
Text:
<input type="text" name="text">
<br>
<input type="submit" value="Verstuur" name="submit">
<input type="Reset" name="Reset"> </form>[/COLOR][COLOR= #007700];[/COLOR] 


[COLOR= #0000BB]$name[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$text[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"<table border=0 width=400 cellpadding=0 cellspacing=0>
<tr><td width=100><b>Schrijver:</b></td><td>$name</td></tr>
<tr><td width=100><b>Datum:</b></td><td>$date</td></tr>
<tr><td colspan=2><b>Text:</b></td></tr>
<tr><td colspan=2>"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]text[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]"</td></tr>
<tr><td colspan=2><HR SIZE=1 NOSHADE></td></tr>
</table>
"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$file[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/fopen"]fopen[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"gastenboek.txt"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"a"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$put[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/fputs"]fputs[/URL] [COLOR= #007700]([/COLOR] [COLOR= #0000BB]$file[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$text[/COLOR] [COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$put[/COLOR][COLOR= #007700]) {[/COLOR]

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Bedankt voor uw inzending[/COLOR][COLOR= #007700];

}[/COLOR]
?>
0
Thijns

Lid · Topicstarter

Berichten
457
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hij geeft dan drie nieuwe errors:

Notice: Undefined index: name in C:xampphtdocstest4.php on line 18

Notice: Undefined variable: date in C:xampphtdocstest4.php on line 23

Notice: Undefined index: text in C:xampphtdocstest4.php on line 23
0
Berichten
832
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Spyrose schreef:
Hij geeft dan drie nieuwe errors:

Notice: Undefined index: name in C:xampphtdocstest4.php on line 18

Notice: Undefined variable: date in C:xampphtdocstest4.php on line 23

Notice: Undefined index: text in C:xampphtdocstest4.php on line 23
Dat zijn geen errors, maar notices die standaard zijn in Xampp.
Je gastenboek zal gewoon werken op deze manier.
0
Thijns

Lid · Topicstarter

Berichten
457
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oke, hardstikke bedankt! Ik zat me al volop te ergeeren aan die waarschuwingen schater
0
Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als het niet werkt: $_GET[text] bestaat waarschijnlijk gewoon niet.
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
probeer

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<font size="5"><b>Gastenboek</b></font><br>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<HR SIZE="1" align=left width=400 NOSHADE>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"gastenboek.txt"[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]
<form action="test4.php" method="get">         
Naam:
<input type="text" name="name">
<br>
Text:
<input type="text" name="text">
<br>
<input type="submit" value="Verstuur" name="submit">
<input type="Reset" name="Reset"> </form>[/COLOR][COLOR= #007700];[/COLOR] 


[COLOR= #0000BB]$name[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$text[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"<table border=0 width=400 cellpadding=0 cellspacing=0>
<tr><td width=100><b>Schrijver:</b></td><td>"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$name[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"</td></tr>
<tr><td width=100><b>Datum:</b></td><td>"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$date[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"</td></tr>
<tr><td colspan=2><b>Text:</b></td></tr>
<tr><td colspan=2>"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]text[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]"</td></tr>
<tr><td colspan=2><HR SIZE=1 NOSHADE></td></tr>
</table>
"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$file[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/fopen"]fopen[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"gastenboek.txt"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"a"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$put[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/fputs"]fputs[/URL] [COLOR= #007700]([/COLOR] [COLOR= #0000BB]$file[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$text[/COLOR] [COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$put[/COLOR][COLOR= #007700]!=[/COLOR]NULL[COLOR= #007700]) {[/COLOR]

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Bedankt voor uw inzending[/COLOR][COLOR= #007700];

}[/COLOR]
?>  





--------------------------------------------------------------------------------
0
Berichten
515
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kyron schreef:
Bedankt voor verbeteringyummie
ik had $name en $date niet gezienyummie
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Geeft niet, ik zag ze ook pas door die error van name en date yummie
0
Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
is het Niet POST inplaats van GET?
0
Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Smiegles schreef:
is het Niet POST inplaats van GET?
Lees regel 7 even goed? Er staat toch duidelijk dat het een get is, dus dan komt het in de url en dan haal je het op als een get. LEZEN
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