Chào mừng!

Bằng cách đăng ký với chúng tôi, bạn sẽ có thể thảo luận, chia sẻ và nhắn tin riêng tư với các thành viên khác trong cộng đồng của chúng tôi.

Đăng ký ngay!
  • Chào Khách,
    Bạn cần liên hệ với admin ??? ZALO & TELEGRAM

Share Code kiểm tra xem SDT thuộc nhà mạng nào đơn giản

Tham gia
24/5/19
Bài viết
679
Lượt Thích
4,586
Coins
48,770
Ngôn ngữ: PHP
Của @Võ Hữu Nhân là JavaScript nên đừng nhầm kk!

PHP:
<center>
<div class="phdr">CODE ĐƠN GIẢN BỞI MẠC QUÂN </div><br>
<?php
  if (isset($_REQUEST['sdt'])){
    $a = $_REQUEST['sdt'];
echo 'Số '.$a.': <b> ' ;
      function validate_username($a){
$check = eregi_replace('([0-9]+)', "", $a);
if(empty($check)){
return true;
} else {
return false;
}
}
$validator = validate_username($a);
if (!$validator){
echo 'Lỗi! Nhập số điện thoại hợp lệ!';

exit;
   }
if ($a ==NULL or strlen($a)<10 OR strlen($a)>11){
echo 'không hợp lệ!';
exit;
}
$a = substr($a, 0,3);
if ($a == '086' OR $a == '096' OR $a == '097' OR $a == '098' OR $a == '032' OR $a == '033' OR $a == '034' OR $a == '035' OR $a == '036' OR $a == '037' OR $a == '038' OR $a == '039') {
echo 'viettel';
exit;
}
if ($a =='089' OR $a =='090' OR $a =='093' OR $a =='070' OR $a =='079' OR $a =='077' OR $a =='076' OR $a =='078') {
echo 'mobifone';
exit;
} 
if ($a =='091' OR $a =='094' OR $a =='088' OR $a =='083' OR $a =='084' OR $a =='085' OR $a =='081' OR $a =='082') {
echo 'vinaphone';
exit;
}
if ($a =='092' OR $a =='056' OR $a =='058')  {
   echo 'vietnamobile';
}
if ($a =='099' OR $a =='059')  {
   echo 'gmobile beeline';
 exit;
}
echo 'không xác định!';
  }   else {
echo '<center><form name="checksdt" action="" method="post">
<input style="border: 1px solid #7E7E7E; -webkit-border-radius: 3px; border-radius: 2px; padding: 2px 2px 2px 5px;max-width: 40%" type="number" name="sdt" placeholder="Số điện thoại" required />
<input type="submit" name="submit" value="KIỂM TRA NGAY" />
</form>';
}
?>
 
Tham gia
7/11/18
Bài viết
352
Lượt Thích
68
Coins
2,060
cũng có đóng góp tý xíu

Mã:
<?php
$GLOBALS["carriers_number"] = [
    '096' => 'Viettel',
    '097' => 'Viettel',
    '098' => 'Viettel',
    '032' => 'Viettel',
    '033' => 'Viettel',
    '034' => 'Viettel',
    '035' => 'Viettel',
    '036' => 'Viettel',
    '037' => 'Viettel',
    '038' => 'Viettel',
    '039' => 'Viettel',
    '090' => 'Mobifone',
    '093' => 'Mobifone',
    '070' => 'Mobifone',
    '071' => 'Mobifone',
    '072' => 'Mobifone',
    '076' => 'Mobifone',
    '078' => 'Mobifone',
    '091' => 'Vinaphone',
    '094' => 'Vinaphone',
    '083' => 'Vinaphone',
    '084' => 'Vinaphone',
    '085' => 'Vinaphone',
    '087' => 'Vinaphone',
    '089' => 'Vinaphone',
    '099' => 'Gmobile',
    '092' => 'Vietnamobile',
    '056' => 'Vietnamobile',
    '058' => 'Vietnamobile',
    '095'  => 'SFone'
];
/**
* Check if a string is started with another string
*
* @param string $needle The string being searched for.
* @param string $haystack The string being searched
* @return bool true if $haystack is started with $needle
*/
function start_with($needle, $haystack) {
    $length = strlen($needle);
    return (substr($haystack, 0, $length) === $needle);
}
/**
* Detect carrier name by phone number
*
* @param string $number The input phone number
* @return bool Name of the carrier, false if not found
*/
function detect_number ($number) {
    $number = str_replace(array('-', '.', ' '), '', $number);
    // $number is not a phone number
    if (!preg_match('/^0[0-9]{8}$/', $number)) return false;
    // Store all start number in an array to search
    $start_numbers = array_keys($GLOBALS["carriers_number"]);
    foreach ($start_numbers as $start_number) {
        // if $start number found in $number then return value of $carriers_number array as carrier name
        if (start_with($start_number, $number)) {
            return $GLOBALS["carriers_number"][$start_number];
        }
    }
    // if not found, return false
    return false;
}
 
Top Bottom
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock
No Thanks