结算表单 - 如果输入的数据与数字

时间:2017-04-14 11:06:25

标签: php regex

你可以帮帮我吗?我正在尝试创建结算信息表单,如果客户输入示例5120293213632438,我将使用' substr'要获得前6个数字,如果这6个数字与512029537030432049等匹配,我将要求提供更多信息 - >增值税号和身份证。

<form action="validate.php" method="post">
  <p>Credit Card Number : <input type="text" name="cc" /></p>
  <p><input type="submit" value="Next"></p>
</form>

validate.php

<?php
$vbv = substr($_POST['cc'], 6);
if($vbv == '512029')
    $flag = strstr($bin, $needle);
    echo "OK";
else 
    echo "I'm not VBV";
?>

1 个答案:

答案 0 :(得分:0)

<?php
ini_set('display_errors', 1);

$array=array(512029, 537030, 432049);  //array of start 6 digits you want  to match

$cc='5120293213632438';//credit card no's you want to match.

if(in_array(substr($cc, 0,6),$array))
{
    echo "First 6 digit matched";
}