Ok, so I'm doing this for school, and it is driving me insane! Basically, I'm supposed to create a script that validates whether a credit card number contains only integers. The script will remove dashes and spaces from the string. After the dashes and spaces are removed, the script should reject the credit card number if it contains any other nonnumeric characters.
So this is the script I came up with:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Validate Credit Card</title>
</head>
<body>
<H1> Validate Credit Card </H1><hr />
<?php
if (!isset($_GET['ccnumber']))
echo "<p>Enter your credit cad 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 cardnumber is $ValidPayment.</p>";
?>
<form action="ValidateCreditCard.php" method="get"
enctype="application/x-www-form-urlencoded">
<p><input type="text" name="ccnumber" size="20" value=""<?php if
(!empty($_GET['ccnumber'])) echo $_GET['ccnumber'] ?> /></p>
<p><input type="submit" value="Validate Credit Card" />
</form><hr />
</body>
</html>
Only problem is everytime I open it in my web browser I get this:
http://i30.tinypic.com/24gmvc3.jpg
The code is all wacko. Can someone pleeeeease help me?
So this is the script I came up with:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Validate Credit Card</title>
</head>
<body>
<H1> Validate Credit Card </H1><hr />
<?php
if (!isset($_GET['ccnumber']))
echo "<p>Enter your credit cad 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 cardnumber is $ValidPayment.</p>";
?>
<form action="ValidateCreditCard.php" method="get"
enctype="application/x-www-form-urlencoded">
<p><input type="text" name="ccnumber" size="20" value=""<?php if
(!empty($_GET['ccnumber'])) echo $_GET['ccnumber'] ?> /></p>
<p><input type="submit" value="Validate Credit Card" />
</form><hr />
</body>
</html>
Only problem is everytime I open it in my web browser I get this:
http://i30.tinypic.com/24gmvc3.jpg
The code is all wacko. Can someone pleeeeease help me?