credit card validation code
Posted: Sat Apr 25, 2009 1:05 pm
This code keeps giving me an error on line 7 (which might be line 8 in this forum display)... but I don't know what exactly is wrong with it since this is a code straight from the book I'm using. Can someone please make some suggestions? Thanks!
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
function myfunc()
{
<?php
if (!empty($_GET[\'ccnumber\'])) echo $_GET[\'ccnumber\'];
if (!isset($_GET[\'ccnumber\']))
echo "<p>Enter your credit card number.</p>";
else {
$Payment = $_GET[\'ccnumber\'];
$ValidPayment = str_replace("-", "", $Payment);
$ValidPayment = str_replace(" ", "", $ValidPayment);
if (!is_numeric($ValidPayment))
echo "<p>You did not enter a valid credit card number!</p>";
else
echo "<p>Your credit card number is $ValidPayment.</p>";
}
?>
}
<title>Validate Credit Card</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>Validate Credit Card</h1><hr />
<form action="ValidateCreditCard.php" method="get"
enctype="application/x-www-form-urlencoded">
<input type="text" name="ccnumber" size="20" onclick="myfunc()" value="Enter Card Number"/>
<input type="submit" value="Validate Credit Card" />
</form><hr />
</body>
</html>