Aarclay schreef:Ik snap niks van dat voorbeeld die je gegeven had..beiden zijn hetzelfde.

Aarclay schreef:Ik snap niks van dat voorbeeld die je gegeven had..beiden zijn hetzelfde.

Desire schreef:Waar loop je vast? Wat heb je al geprobeerd?Ik snap niks van dat voorbeeld die je gegeven had..Eerdere citaten tonen
Aarclay schreef:beiden zijn hetzelfde.

Aarclay schreef:Nog niks, maar als ik het zo lees en zie dan snap ik er al niks van.Waar loop je vast? Wat heb je al geprobeerd?Eerdere citaten tonen
Desire schreef:Ik snap niks van dat voorbeeld die je gegeven had..Eerdere citaten tonen
Aarclay schreef:beiden zijn hetzelfde.
Desire schreef:Probeer het eerst eens dan?Nog niks, maar als ik het zo lees en zie dan snap ik er al niks van.
[COLOR= #0000BB]<?php
$testcase[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"The quick brown fox jumps over the lazy dog"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/ctype_alnum"]ctype_alnum[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$testcase[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"The string "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$testcase[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" consists of all letters or digits.n"[/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]"The string "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$testcase[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" does not consist of all letters or digits.n"[/COLOR][COLOR= #007700];
}[/COLOR]
?> Aarclay schreef:Ja maar hoe moet ik dat dan doen als ik de code toevoeg in de database. Dit zijn alleen echo`sProbeer het eerst eens dan?Eerdere citaten tonen
Desire schreef:Nog niks, maar als ik het zo lees en zie dan snap ik er al niks van.[COLOR= #0000BB]<?php $testcase[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"The quick brown fox jumps over the lazy dog"[/COLOR][COLOR= #007700];[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/ctype_alnum"]ctype_alnum[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$testcase[/COLOR][COLOR= #007700])) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"The string "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$testcase[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" consists of all letters or digits.n"[/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]"The string "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$testcase[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" does not consist of all letters or digits.n"[/COLOR][COLOR= #007700]; }[/COLOR] ?>
[COLOR= #0000BB]<?php
$testcase[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"The quick brown fox jumps over the lazy dog"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/ctype_alnum"]ctype_alnum[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$testcase[/COLOR][COLOR= #007700])) {[/COLOR]
[COLOR= #FF8000]// true, plaats in database[/COLOR]
[COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #FF8000]// false, doe niets...[/COLOR]
[COLOR= #007700]}[/COLOR]
?> 

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]){[/COLOR]
[COLOR= #0000BB]$select[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM beta_code WHERE code = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]code[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$bestaatcode[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$test[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"De code is <b>succesvol</b> toegevoegd.<br> <a href="index.php">Klik hier om terug te gaan naar de admin</a>."[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/ctype_alnum"]ctype_alnum[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$test[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bestaatcode[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO beta_code (id, code) VALUES (, "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]code[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]")"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
}
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Deze code bestaat al!<br> <a href="javascript:history.back(1)">Klik hier om terug te gaan</a>.<br>[/COLOR][COLOR= #007700];
}
}[/COLOR]
?> Aarclay schreef:Ik weet het echt niet meerWaarom zet je je melding in die functie? Moet je niet de code uit je $_POST[code] controleren?
Please help me
Ik weet dat je alleen maar tips en kleine stukjes codes geeft, maar ik kom er serieus niet uit


if (ctype_alnum($_POST[code])) { - voer query uit (mysql_query)
- kijk of de code code bestaat (mysql_num_rows() )
* zo ja, toon een melding dat de code al bestaat
* Zo nee, voer de ctype_alnum() functie uit op $_POST
- Komt niet overeen met de validatie: Foutmelding tonen
- Komt wel overeen: Plaats de INSERT query.
* Kijk of deze gelukt is, zo niet: error: mysql_error()
* Zo wel: Profit, toon een leuke melding naar de gebruiker toe.
.Aarclay schreef:Je wilt toch je de code uit het formulier controleren?if (ctype_alnum($_POST[code])) {
- voer query uit (mysql_query)
- kijk of de code code bestaat (mysql_num_rows() )
* zo ja, toon een melding dat de code al bestaat
* Zo nee, voer de ctype_alnum() functie uit op $_POST
- Komt niet overeen met de validatie: Foutmelding tonen
- Komt wel overeen: Plaats de INSERT query.
* Kijk of deze gelukt is, zo niet: error: mysql_error()
* Zo wel: Profit, toon een leuke melding naar de gebruiker toe. Desire schreef:Is het dan wel SQLi?Je wilt toch je de code uit het formulier controleren?Eerdere citaten tonen
Aarclay schreef:if (ctype_alnum($_POST[code])) {
De stappen die je moet volgen:- voer query uit (mysql_query) - kijk of de code code bestaat (mysql_num_rows() ) * zo ja, toon een melding dat de code al bestaat * Zo nee, voer de ctype_alnum() functie uit op $_POST - Komt niet overeen met de validatie: Foutmelding tonen - Komt wel overeen: Plaats de INSERT query. * Kijk of deze gelukt is, zo niet: error: mysql_error() * Zo wel: Profit, toon een leuke melding naar de gebruiker toe.
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]){[/COLOR]
[COLOR= #0000BB]$select[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM beta_code WHERE code = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]code[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$bestaatcode[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bestaatcode[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Deze code bestaat al!<br> <a href="javascript:history.back(1)">Klik hier om terug te gaan</a>.<br>[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/ctype_alnum"]ctype_alnum[/URL][COLOR= #007700]()){[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO beta_code (id, code) VALUES (, "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]code[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]")"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][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]De code is <b>succesvol</b> toegevoegd.<br> <a href="index.php">Klik hier om terug te gaan naar de admin</a>.[/COLOR][COLOR= #007700];
}
}
}[/COLOR]
?> [COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]){[/COLOR]
[COLOR= #0000BB]$select[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM beta_code WHERE code = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]code[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$bestaatcode[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bestaatcode[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Deze code bestaat al!<br> <a href="javascript:history.back(1)">Klik hier om terug te gaan</a>.<br>[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO beta_code (id, code) VALUES (, "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/ctype_alnum"]ctype_alnum[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]code[/COLOR][COLOR= #007700]])) .[/COLOR] [COLOR= #DD0000]")"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][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]De code is <b>succesvol</b> toegevoegd.<br> <a href="index.php">Klik hier om terug te gaan naar de admin</a>.[/COLOR][COLOR= #007700];
}
}[/COLOR]
?>