<?php
require_once "class.error.php";
$e =
new error;
require_once "class.credit.php";
$cc =
new credit;
if($_POST){
$cc_number =
$_POST['cc_number'];
$expire_month =
$_POST['expire_month'];
$expire_year =
$_POST['expire_year'];
$cc_cvv =
$_POST['cc_cvv'];
$date =
$expire_month .
$expire_year;
$cc->
validate($cc_number,
$cc_cvv,
$date);
if($e->
countErrors() ==
0){
//process form
header("location: somewhere.php");
die();
}
}
?>
<?php $e->
showErrors();
?>
<form method=
"post" action=
"<?php echo $_SERVER['PHP_SELF'] ?>">
<table border=
"0" cellpadding=
"4" width=
"450">
<tr>
<td width=
"200" class=
"tbl_left">Payment Type: </td>
<td width=
"250" class=
"tbl_right">Credit Card</td>
</tr>
<tr>
<td
class=
"tbl_left">Card Holder Name: </td>
<td
class=
"tbl_right"><input type=
"text" name=
"cc_name" /></td>
</tr>
<tr>
<td
class=
"tbl_left">Card Type: </td>
<td
class=
"tbl_right"><select name=
"cc_type">
<option value=
"American Express">American Express</option>
<option value=
"Discover">Discover</option>
<option value=
"Master Card">Master Card</option>
<option value=
"Visa">Visa</option>
</select>
</td>
</tr>
<tr>
<td
class=
"tbl_left">Credit Card Number: </td>
<td
class=
"tbl_right"><input type=
"text" name=
"cc_number" /></td>
</tr>
<tr>
<td
class=
"tbl_left">Expiration
Date: </td>
<td
class=
"tbl_right"><select name=
"expire_month">
<option value=
"01">January</option>
<option value=
"02">February</option>
<option value=
"03">March</option>
<option value=
"04">April</option>
<option value=
"05">May</option>
<option value=
"06">June</option>
<option value=
"07">July</option>
<option value=
"08">August</option>
<option value=
"09">September</option>
<option value=
"10">October</option>
<option value=
"11">November</option>
<option value=
"12">December</option>
</select>
<select name=
"expire_year">
<?php
for($x=
date(Y
);
$x<=
2050;
$x++
){
echo '<option value="'.
substr($x,
-2).
'">'.
$x.
'</option>'.
"\n";
}
?>
</select>
</td>
</tr>
<tr>
<td
class=
"tbl_left">CVV Number:</td>
<td
class=
"tbl_right"><input type=
"text" name=
"cc_cvv" size=
"5" maxlength=
"4" /></td>
</tr>
<tr>
<td
class=
"tbl_left">Enter a Promo Code: </td>
<td
class=
"tbl_right"><input type=
"text" name=
"promo_code" /></td>
</tr>
</table>
</form>