-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck.php
70 lines (59 loc) · 1.86 KB
/
check.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
if (isset($_GET['number_entered'])) {
$number= $_GET['number_entered'];
if ($number == "") {
$error = "The field cant be empty";
}else{
if (validatecard($number) !== false) {
if ($type == "Visa") {
$success = "<img style='width: 70px; height: px;' src='img/visa.png'> Credit Card is valid";
}elseif ($type == "Mastercard") {
$success = "<img style='width: 70px; height: ;' src='img/mastercard.png'> Credit Card is valid";
}elseif ($type == "Amex") {
$success = "<img style='width: 70px; height: ;' src='img/amex.png'> Credit Card is valid";
}elseif ($type == "Discover") {
$success = "<img style='width: 70px; height: 50px;' src='img/discover.png'> Credit Card is valid";
}
}else{
$error = " This credit card number is invalid";
}
validatecard($number);
}
}
// $submitbutton= $_GET['submitbutton'];
function validatecard($number)
{
global $type;
$cardtype = array(
"Visa" => "/^4[0-9]{12}(?:[0-9]{3})?$/",
"Mastercard" => "/^5[1-5][0-9]{14}$/",
"Amex" => "/^3[47][0-9]{13}$/",
"Discover" => "/^6(?:011|5[0-9]{2})[0-9]{12}$/",
);
if (preg_match($cardtype['Visa'],$number))
{
$type= "Visa";
return 'Visa';
}
else if (preg_match($cardtype['Mastercard'],$number))
{
$type= "Mastercard";
return 'Mastercard';
}
else if (preg_match($cardtype['Amex'],$number))
{
$type= "Amex";
return 'Amex';
}
else if (preg_match($cardtype['Discover'],$number))
{
$type= "Discover";
return 'Discover';
}
else
{
return false;
}
}
include 'messages.php';
?>