Beveiligen

Gestart doorDesire47 reacties344 weergaven

48 berichten · pagina 2 van 4

Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
beiden zijn hetzelfde.
Ik snap niks van dat voorbeeld die je gegeven had..confused
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja. Ik gebruik alleen liever preg_match() (persoonlijke voorkeur). Omdat ik meestal wel meer voorwaarden aan iets toevoeg.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Desire schreef:
Eerdere citaten tonen
Aarclay schreef:
beiden zijn hetzelfde.
Ik snap niks van dat voorbeeld die je gegeven had..confused
Waar loop je vast? Wat heb je al geprobeerd?
0
Marv

Lid

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
preg_match(/[a-zA-Z0-9]/, mysql_real_escape_string($_POST[code])) ? bloos
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Eerdere citaten tonen
Desire schreef:
Eerdere citaten tonen
Aarclay schreef:
beiden zijn hetzelfde.
Ik snap niks van dat voorbeeld die je gegeven had..confused
Waar loop je vast? Wat heb je al geprobeerd?
Nog niks, maar als ik het zo lees en zie dan snap ik er al niks van.

toevoeging op 13 maart 2012, 19:28:29:
@efferinie ff proberen

toevoeging op 13 maart 2012, 19:30:30:
@efferinie werkt niet
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Desire schreef:
Nog niks, maar als ik het zo lees en zie dan snap ik er al niks van.
Probeer het eerst eens dan?

[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]
?>
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Eerdere citaten tonen
Desire schreef:
Nog niks, maar als ik het zo lees en zie dan snap ik er al niks van.
Probeer het eerst eens dan?

[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]
?>

Ja maar hoe moet ik dat dan doen als ik de code toevoeg in de database. Dit zijn alleen echo`s
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
[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]
?>


Zie de gele comments.
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ff proberen.

toevoeging op 13 maart 2012, 19:44:46:
Ik kom er echt niet uit.. confused
Ik heb nu ditconfused
[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]
?>
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Waarom zet je je melding in die functie? Moet je niet de code uit je $_POST[code] controleren?
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Waarom zet je je melding in die functie? Moet je niet de code uit je $_POST[code] controleren?
Ik weet het echt niet meerconfused Please help meconfused Ik weet dat je alleen maar tips en kleine stukjes codes geeft, maar ik kom er serieus niet uitconfusedconfusedconfused
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
if (ctype_alnum($_POST[code])) {


Je wilt toch je de code uit het formulier controleren?

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.


Hier moet het denk ik vast wel mee lukken smile.
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
if (ctype_alnum($_POST[code])) {
Je wilt toch je de code uit het formulier controleren?

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.


Is het dan wel SQLi? Ofso..
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Desire schreef:
Eerdere citaten tonen
Aarclay schreef:
if (ctype_alnum($_POST[code])) {
Je wilt toch je de code uit het formulier controleren?

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.

Is het dan wel SQLi?

Dat mag je zelf inbouwen, het toevoegen van een i achter de mysql_prefix is vaak al voldoende, en anders is http://php.net/mysqli je vriend.
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb nu dit:

[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]
    
    
?>


Daarvoor had ik dit:

[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]
    
    
?>


Allebij werkt niet
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