Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1.Create a new document in your text editor. 2. Type the declaration, element, document head, and element. Use the strict DTD and Validate Credit Card
1.Create a new document in your text editor. 2. Type the declaration, element, document head, and
element. Use the strict DTD and "Validate Credit Card" as the content of theValidate Credit Card
4. Add the following script section to the document body: 5. Declare a $CreditCard array that contains three values: an empty string, a valid credit card number with numbers and dashes, and a credit card number with four initial uppercase letter Os. $CreditCard = array( "", "8910-1234-5678-6543", "OOOO-9123-4567-0123"); 6. Add the following statements to iterate through each of the elements in the $CreditCard array to determine if the ele- ment contains a value. foreach ($CreditCard as $CardNumber) { if (empty($CardNumber)) echo "
This Credit Card Number is invalid because it contains an empty string.
"; 7. Add the following else clause to validate the credit card number. The code uses str_replace() functions to remove any dashes and spaces in the number. Then, a nested if...else statement checks whether the new value is numeric. If the number is not numeric, a warning is displayed. If the number is numeric, the modified credit card number is displayed in the Web browser. else { $CreditCardNumber = $CardNumber; $CreditCardNumber = str_replace("-", "", $CreditCardNumber); $CreditCardNumber = str_replace(" ", "", $CreditCardNumber); if (!is_numeric($CreditCardNumber)) echo "Credit Card Number " . $CreditCardNumber . " is not a valid Credit Card number because it contains a non-numeric character.
";else } } echo "
Credit Card Number " . $CreditCardNumber . " is a valid Credit Card number.
"; 8. Save the document as ValidateCreditCard.php in the Projects directory for Chapter 3 and upload the file to the server. 9. Open ValidateCreditCard.php in your Web browser by enter- ing the following URL: http://Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started