Hallo allemaal,
Ik heb net een scriptje van het internet geplukt om wat mee te klooien om wat beter in PHP te worden (vandaar dat je wel wat vragen van me de komende tijd kunt verwachten), en ik kom de Undefined index error tegen. Hieronder de code.
En hieronder de ERROR.
Kan iemand mij vertellen wat hier fout gaat en hoe ik dit in de toekomst op kan lossen?
Ik heb net een scriptje van het internet geplukt om wat mee te klooien om wat beter in PHP te worden (vandaar dat je wel wat vragen van me de komende tijd kunt verwachten), en ik kom de Undefined index error tegen. Hieronder de code.
<body>
[COLOR= #0000BB]<?[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"connect.php"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"functions.php"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]] &&[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]na_am[/COLOR][COLOR= #007700]] &&[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]beri_cht[/COLOR][COLOR= #007700]] &&[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]tit_el[/COLOR][COLOR= #007700]])
{[/COLOR]
[COLOR= #0000BB]$datum[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"d.m.Y"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]beri_cht[/COLOR][COLOR= #007700]] =[/COLOR] filter[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]beri_cht[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"INSERT INTO topics SET id = , titel = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]tit_el[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]", bericht = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]beri_cht[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]", datum = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$datum[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]", naam = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]na_am[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$res[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Topic toegevoegd! Ga naar het <a href="topics.php">topic overzicht</a>"[/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]"Topic <b>niet</b> toegevoegd! Probeer het <a href=""[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$PHP_SELF[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"">opnieuw</a>"[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]] ||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]na_am[/COLOR][COLOR= #007700]] ||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]beri_cht[/COLOR][COLOR= #007700]] ||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]tit_el[/COLOR][COLOR= #007700]])
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Niet alle velden ingevult! Probeer het <a href=""[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$PHP_SELF[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"">opnieuw</a>"[/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]"<center>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<table border="0" cellspacing="0" cellpadding="5" align="center">"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<form method="POST" action=""[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$PHP_SELF[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"">"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td>Je naam:*</td></tr>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td><input type="text" name="na_am"></td></tr>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td> </td></tr>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td>Titel:*</td></tr>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td><input type="text" name="tit_el"></td></tr>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td> </td></tr>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td>Bericht:*</td></tr>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td><textarea name="beri_cht" rows="5" cols="15"></textarea></td></tr>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td>Alle velden zijn verplicht! </td></tr>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr><td><input type="submit" name="submit" value="Plaats!" class="buttons"> <input type="reset" value="Wis" class="buttons"></td></tr>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</form>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</table>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</center>"[/COLOR][COLOR= #007700];
}[/COLOR]
?>
</body>
</html> En hieronder de ERROR.
Notice: Undefined index: submit in C:xampphtdocsForumaddtopic.php on line 15
Notice: Undefined index: submit in C:xampphtdocsForumaddtopic.php on line 32
Notice: Undefined index: na_am in C:xampphtdocsForumaddtopic.php on line 32
Notice: Undefined index: beri_cht in C:xampphtdocsForumaddtopic.php on line 32
Notice: Undefined index: tit_el in C:xampphtdocsForumaddtopic.php on line 32
Notice: Undefined variable: PHP_SELF in C:xampphtdocsForumaddtopic.php on line 41 Kan iemand mij vertellen wat hier fout gaat en hoe ik dit in de toekomst op kan lossen?
34:
