Mischien is het al wel bekend dat ik een beginnend php scripter ben die nog veel moet
leren en oefenen. Ik wil even hier laten zien hoe mijn eerste php/mysql berichtenbalk
is gemaakt. Ik het uithalen en opslaan geleerd van w3schools.com en het database tabel
scripten van phptuts.nl
Ik zou het leuk vinden als mensen hem gaan gebruiken. En mij info geven over fijn of slecht of wat er beter kan
Eigenlijk had ik nog een id moeten maken omdat dat makkelijker is zeggen ze:
sql.sql
post.php
verwerk.php
berichtenbalkzelf.php
leren en oefenen. Ik wil even hier laten zien hoe mijn eerste php/mysql berichtenbalk
is gemaakt. Ik het uithalen en opslaan geleerd van w3schools.com en het database tabel
scripten van phptuts.nl
Ik zou het leuk vinden als mensen hem gaan gebruiken. En mij info geven over fijn of slecht of wat er beter kan
Eigenlijk had ik nog een id moeten maken omdat dat makkelijker is zeggen ze:
sql.sql
CREATE TABLE paullshoutbox (
naam varchar(20) NOT NULL,
bericht varchar(100) NOT NULL,
ip varchar(20) NOT NULL
) post.php
<form method="post" action="versturen.php">
<b>Naam</b><br/>
<input type="text" name="naam" maxlength="20" /><br/><br/>
<b>bericht</b><br/>
<input type="text" name="bericht" maxlength="100" /><br/>
<input type="submit" value="Post bericht!" />
</form> verwerk.php
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// Deze berichtenbalk is gescript in php en mysql door paul van beek[/COLOR]
[COLOR= #0000BB]$host[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$database[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"database_naam"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$wachtwoord[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$host"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"$database"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"$wachtwoord"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Could not connect: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
}[/COLOR]
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$database[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$ip[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR]REMOTE_ADDR[COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$naam[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR]htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR]naam[COLOR= #007700]]));[/COLOR]
[COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR]htmlspecialchars[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR]bericht[COLOR= #007700]]));[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"INSERT INTO paullshoutbox (naam, bericht, ip)
VALUES ($naam, $bericht, $ip)"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]))
{[/COLOR]
[URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Error: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je bericht is toegevoegd"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?> berichtenbalkzelf.php
<marquee onmouseover="this.stop()" onmouseout="this.start()">
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// Berichtenbalk gemaakt door Paul van Beek[/COLOR]
[COLOR= #0000BB]$host[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$database[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"database_naam"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$wachtwoord[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$con[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]$host[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]$database[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]$wachtwoord[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Kan niet connecten met database[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
}[/COLOR]
[COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$database[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$ophalen[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]SELECT * FROM paullshoutbox ORDER BY naam[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ophalen[/COLOR][COLOR= #007700]))
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rij[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]].[/COLOR] [COLOR= #DD0000] - [/COLOR] [COLOR= #007700].[/COLOR][COLOR= #0000BB]$rij[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] || [/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?>
</marquee> 

, bedankt