Wat doe ik fout?

Gestart doorOne2xs3 reacties23 weergaven

4 berichten · pagina 1 van 1

One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Wat doe ik fout, de videoid wordt wel opgeslagen en de naam en reactie blijven leeg:

[COLOR= #0000BB]<?[/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]verzenden[/COLOR][COLOR= #007700]]))
{[/COLOR]
 
[COLOR= #0000BB]$voornaam[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]voornaam[/COLOR][COLOR= #007700]]);[/COLOR] 
[COLOR= #0000BB]$email[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]);[/COLOR] 
[COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]);[/COLOR] 
 
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO reacties (videoid, naam, reactie) VALUES ("[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$naam[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$reactie[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR] 
 
[URL="http://www.php.net/print"]print[/URL] [COLOR= #DD0000]"Reactie toegevoegd"[/COLOR][COLOR= #007700]; 
  }[/COLOR] 
[URL="http://www.php.net/else"]else[/URL] 
  [COLOR= #007700]{[/COLOR]
  ?>
  <center>
<form action="" method="POST">
Naam: <br><input type="text" name="naam"><br /> 
Reactie: <br><textarea name="reactie" rows="5" cols="30"></textarea><br />  
<input type="submit" name="verzenden" value="verzenden"> 
</form> </center>
[COLOR= #0000BB]<?[/COLOR] 
  [COLOR= #007700]}[/COLOR] 
?>
0
Janm

Lid

Berichten
6.170
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Het textvak heet naam, en wordt gepost als voornaam? Zelfde bij de reactie.

[COLOR= #0000BB]<?[/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]verzenden[/COLOR][COLOR= #007700]]))
{[/COLOR]
 
[COLOR= #0000BB]$voornaam[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]);[/COLOR] 
[COLOR= #0000BB]$email[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]);[/COLOR] 
[COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]]);[/COLOR] 
 
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO reacties (videoid, naam, reactie) VALUES ("[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$naam[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$reactie[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR] 
 
[URL="http://www.php.net/print"]print[/URL] [COLOR= #DD0000]"Reactie toegevoegd"[/COLOR][COLOR= #007700]; 
  }[/COLOR] 
[URL="http://www.php.net/else"]else[/URL] 
  [COLOR= #007700]{[/COLOR]
  ?>
  <center>
<form action="" method="POST">
Naam: <br><input type="text" name="naam"><br /> 
Reactie: <br><textarea name="reactie" rows="5" cols="30"></textarea><br />  
<input type="submit" name="verzenden" value="verzenden"> 
</form> </center>
[COLOR= #0000BB]<?[/COLOR] 
  [COLOR= #007700]}[/COLOR] 
?>


Ik ben dan geen php wonder maar dit zag ik dan wel weer meteen.
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Janm schreef:
Het textvak heet naam, en wordt gepost als voornaam? Zelfde bij de reactie.
[COLOR= #0000BB]<?[/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]verzenden[/COLOR][COLOR= #007700]]))
{[/COLOR]
 
[COLOR= #0000BB]$voornaam[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]);[/COLOR] 
[COLOR= #0000BB]$email[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]);[/COLOR] 
[COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/addslashes"]addslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]]);[/COLOR] 
 
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO reacties (videoid, naam, reactie) VALUES ("[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$naam[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$reactie[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR] 
 
[URL="http://www.php.net/print"]print[/URL] [COLOR= #DD0000]"Reactie toegevoegd"[/COLOR][COLOR= #007700]; 
  }[/COLOR] 
[URL="http://www.php.net/else"]else[/URL] 
  [COLOR= #007700]{[/COLOR]
  ?>
  <center>
<form action="" method="POST">
Naam: <br><input type="text" name="naam"><br /> 
Reactie: <br><textarea name="reactie" rows="5" cols="30"></textarea><br />  
<input type="submit" name="verzenden" value="verzenden"> 
</form> </center>
[COLOR= #0000BB]<?[/COLOR] 
  [COLOR= #007700]}[/COLOR] 
?>


Ik ben dan geen php wonder maar dit zag ik dan wel weer meteen.

Oeps, foutje.. yummie
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Een goede titel verzinnen, kleine moeite.

Anyway:
- Gebruik geen addslashes() voor data in je query, je wilt je data niet om zeep helpen.
Het gebruik van mysql_real_escape_string() is de enige juiste oplossing.

- Gebruik in ieder geval if($_SERVER[REQUEST_METHOD] == "POST") {. Niet elke browser geeft altijd de submit door als je controleert op $_POST[submit] o.i.d., en daar wil je nooit alleen maar op controleren. Dus kijk naar deze $_SERVER-variabele.

- Ga er nooit zomaar vanuit dat een query gelukt is zonder het te controleren. Pas foutafhandeling toe. In combinatie met error_reporting op 0, en display_errors op 1 ga je zeker heel PHP bij elkaar vloeken doordat de query niet gelukt is en het toch gemeld is.

Foutafhandeling, het MOET gewoon wink
Dus op de schop met deze lap code.
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