Hallo,
Omdat ik me gister bezig had gehouden met MySQLi heb ik nu een gastenboekje gemaakt.
SQL :
Afbeelding niet beschikbaarDe bron kon niet worden geladen (plaatjes.tk).Bron openen ↗
Graag jullie reacties.
Groetjes, Maarten
Omdat ik me gister bezig had gehouden met MySQLi heb ik nu een gastenboekje gemaakt.
[COLOR= #0000BB]<?php
$begin[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]rstyle_[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$mysql[/COLOR] [COLOR= #007700]= new[/COLOR] MySQLi[COLOR= #007700]([/COLOR][COLOR= #DD0000]localhost[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$begin[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]mysqli[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]pass[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$begin[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]mysqli[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$berichtenQuery[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM gb LIMIT 10"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$berichten[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$berichtenQuery[/COLOR][COLOR= #007700]->[/COLOR]fetch_assoc[COLOR= #007700]())
{[/COLOR]
?>
<table style="margin-top:10px;border-width:1px;border-style:solid;width:50%;min-height:150px;text-overflow: ellipsis-word;">
<tr>
<td>[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$berichten[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]);[/COLOR] ?></td>
</tr>
<tr>
<td>[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/nl2br"]nl2br[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$berichten[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]);[/COLOR] ?></td>
</tr>
</table>
[COLOR= #0000BB]<?[/COLOR]
[COLOR= #007700]}[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"POST"[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/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]plaatsen[/COLOR][COLOR= #007700]]))
{[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]))
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Vul aub een naam in![/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]))
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Vul aub een bericht in![/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO gb (naam,bericht) VALUES ("[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]])).[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]])).[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]U reactie is geplaatst![/COLOR][COLOR= #007700];
}
}
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
?>
<form action="" method="post">
<table>
<tr>
<td>Naam:</td>
<td><input type="text" name="naam" /></td>
</tr>
<tr>
<td>Bericht:</td>
<td><textarea rows="5" cols="50" name="bericht"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="Post!" name="plaatsen" /></td>
</tr>
</table>
</form>
[COLOR= #0000BB]<?[/COLOR]
[COLOR= #007700]}[/COLOR]
?> SQL :
Afbeelding niet beschikbaarDe bron kon niet worden geladen (plaatjes.tk).Bron openen ↗Graag jullie reacties.
Groetjes, Maarten


21: