Beveiligen

Gestart doorDesire47 reacties344 weergaven

48 berichten · pagina 3 van 4

Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Ga eerst eens foutafhandeling toevoegen op je eerste query uit $select.
ctype_alnum($_POST[code]) geeft true of false uit, deze hoort niet in een query.

Zie mijn vorige post eens en loop het stappenschema eens door.
Ook raad ik aan om eens de basis van PHP goed te leren, ik zie je veel fouten maken.

if(ctype_alnum()){


Je wou toch *iets* controleren?

mysql_query("INSERT INTO beta_code (id, code) VALUES (, " . mysql_real_escape_string(ctype_alnum($_POST[code])) . ")") or trigger_error(mysql_error());


Dit klopt ook niet, die ctype_alnum() geeft true of false uit.

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

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][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][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]code[/COLOR][COLOR= #007700]])) {[/COLOR]
            [COLOR= #0000BB]$insert[/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/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$insert[/COLOR][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] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
            [COLOR= #FF8000]// query mislukt: mysql_error()[/COLOR]
           [COLOR= #007700]}
      }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
      [COLOR= #FF8000]// niet geldig. code voldoet niet aan de validatie.[/COLOR]
      [COLOR= #007700]}
        }
        
    }
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #FF8000]// query mislukt, toon mysql_error()[/COLOR]
[COLOR= #007700]}[/COLOR]    
?>


Zoiets... untested, maar de opbouw klopt zo ongeveer
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hij werkt bedankt!!!
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Woei smile
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nieuwe fout.

[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_message WHERE message = "[/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]message[/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]$error[/COLOR] [COLOR= #007700]=[/COLOR] [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/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$bestaatmessage[/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]$bestaatmessage[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]
         [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Deze message 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][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]message[/COLOR][COLOR= #007700]])) {[/COLOR]
            [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO beta_message (id, message) 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]message[/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 message 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/else"]else[/URL] [COLOR= #007700]{[/COLOR]
           [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]De message voldoet niet aan de voorgestelde eisen, hier zijn de eisen: u mag alleen letters(ABC etc.) en/of cijfers(123 etc.) gebruiken.[/COLOR][COLOR= #007700];
           }
        }
        
    }
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700];
}[/COLOR]    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user_status[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR]
?>


Dit is op de message maken pagina, dus niet de code aanmaken maar een message.
Alleen nu wil ik er wel (punten(.)) in kunnen doen en (enters) Alleen dan geeft hij deze fout:
echo De message voldoet niet aan de voorgestelde eisen, hier zijn de eisen: u mag alleen letters(ABC etc.) en/of cijfers(123 etc.) gebruiken.;


Hoe kan ik dit oplossen.
0
Berichten
1.544
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Desire schreef:
Nieuwe fout.
[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_message WHERE message = "[/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]message[/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]$error[/COLOR] [COLOR= #007700]=[/COLOR] [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/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$bestaatmessage[/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]$bestaatmessage[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]
         [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Deze message 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][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]message[/COLOR][COLOR= #007700]])) {[/COLOR]
            [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO beta_message (id, message) 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]message[/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 message 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/else"]else[/URL] [COLOR= #007700]{[/COLOR]
           [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]De message voldoet niet aan de voorgestelde eisen, hier zijn de eisen: u mag alleen letters(ABC etc.) en/of cijfers(123 etc.) gebruiken.[/COLOR][COLOR= #007700];
           }
        }
        
    }
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700];
}[/COLOR]    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user_status[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR]
?>


Dit is op de message maken pagina, dus niet de code aanmaken maar een message.
Alleen nu wil ik er wel (punten(.)) in kunnen doen en (enters) Alleen dan geeft hij deze fout:
echo De message voldoet niet aan de voorgestelde eisen, hier zijn de eisen: u mag alleen letters(ABC etc.) en/of cijfers(123 etc.) gebruiken.;


Hoe kan ik dit oplossen.

Ook niet getest: Hij kan spaties/enters/getallen/letters/punten

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] check_code[COLOR= #007700]([/COLOR][COLOR= #0000BB]$code[/COLOR][COLOR= #007700]) {[/COLOR]

    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/A[a-zA-Z0-9sn.]*Z/[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$code[/COLOR][COLOR= #007700])) {[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] true[COLOR= #007700];
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] false[COLOR= #007700];
    }

}[/COLOR]
?>
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Spoiler tonen
Jenner (link):
Desire schreef:
Nieuwe fout.[/spoiler]
[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_message WHERE message = "[/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]message[/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]$error[/COLOR] [COLOR= #007700]=[/COLOR] [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/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$bestaatmessage[/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]$bestaatmessage[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]
         [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Deze message 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][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]message[/COLOR][COLOR= #007700]])) {[/COLOR]
            [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO beta_message (id, message) 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]message[/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 message 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/else"]else[/URL] [COLOR= #007700]{[/COLOR]
           [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]De message voldoet niet aan de voorgestelde eisen, hier zijn de eisen: u mag alleen letters(ABC etc.) en/of cijfers(123 etc.) gebruiken.[/COLOR][COLOR= #007700];
           }
        }
        
    }
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700];
}[/COLOR]    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user_status[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR]
?>


Dit is op de message maken pagina, dus niet de code aanmaken maar een message.
Alleen nu wil ik er wel (punten(.)) in kunnen doen en (enters) Alleen dan geeft hij deze fout:
echo De message voldoet niet aan de voorgestelde eisen, hier zijn de eisen: u mag alleen letters(ABC etc.) en/of cijfers(123 etc.) gebruiken.;


Hoe kan ik dit oplossen.

Ook niet getest: Hij kan spaties/enters/getallen/letters/punten

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] check_code[COLOR= #007700]([/COLOR][COLOR= #0000BB]$code[/COLOR][COLOR= #007700]) {[/COLOR]

    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/A[a-zA-Z0-9sn.]*Z/[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$code[/COLOR][COLOR= #007700])) {[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] true[COLOR= #007700];
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] false[COLOR= #007700];
    }

}[/COLOR]
?>


Oke dat werkt, alleen slaat hij de enters niet op.
0
Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
nl2br();
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sebastiaanh schreef:
nl2br();
Ja maar hoe plaats ik dat.
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Om de post variable heen
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rogier schreef:
Om de post variable heen
Werkt niet.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Hij slaat de enters wel op als linebreak thumbsdown

Gebruik nl2br() over je output:

echo nl2br($string);


Dit gebruik je dus NIET in je query.
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Klopt was mijn fout. Het kan wel alleen dan krijg je in de DB
te staan. En als je er dan htmlentities overheen gooit wordt de
gewoon "
"
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik probeer het morgen, heb het nu druk.
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb geen idee hoe of wat ik moet doen bij die nl2brconfused
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
zie http://php.net/nl2br

Gebruiken in je output.
Meer zeg ik niet, kan je zelf wel vinden. Als je die PM had gelaten had ik wel wat uitgebreider geweest.
Hulp vragen per PM is not done. Ik ben hier vrijwillig, en laat me zeker niet niet door iemand aan mijn mouw trekken om naar een topic te kijken.

Als ik iets wil beantwoorden, bepaal ik dat volledig zelf.
Dus laat dit in het vervolg.
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