Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>ЕГН</title>
- </head>
- <body>
- <h1>ЕГН валидатор</h1>
- <form action="#">
- ЕГН: <input type="text" name="egn" maxlength="10" required>
- <input type="submit" value="Провери" name="check">
- </form>
- <?php
- if(isset($_GET["check"])){
- $egn = $_GET["egn"];
- if (strlen($egn) == 10 && is_numeric($egn)){
- $control = $egn[0]*2 + $egn[1]*4 + $egn[2]*8 + $egn[3]*5 + $egn[4]*10 + $egn[5]*9 + $egn[6]*7 + $egn[7]*3 + $egn[8]*6;
- $control = $control % 11;
- if ($control == 10){
- $control = 0;
- }
- if ($control == $egn[9]){
- echo "Валидно ЕГН!";
- if ($egn[8] % 2 == 0){
- echo "<p>Мъж</p>";
- } else {
- echo "<p>Жена</p>";
- }
- } else {
- echo "Невалидна контролна цифра за ЕГНто!";
- }
- } else {
- echo "Невалидно ЕГН!";
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement