subject

In this exercise, you will 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 non-numeric characters. Complete the steps below: 1. Open Notepad++ and create a new document.
2. Type the declaration, element, header information, and
element. Use the strict DTD and "Validate Credit Card" as the content of the
element.
3. Add the following text and elements to the document body:
Validate 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",
"-9123-4567-0123");
6. Add the following statements to iterate through each of the elements in the $CreditCard array to determine if the element 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 ValidCreditCardLastname. php (Lastname should be your last
name) in the Projects directory for Chapter 3. Open it in your Web browser to see how it
renders. Test the script to see if it displays a message for an empty string, strips dashes
and spaces from the credit card numbers, and identifies which credit card numbers are
valid.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:30
Which number on the image above correctly indicates the name of a folder in this url? a.1b.2c.3d.4
Answers: 2
question
Computers and Technology, 22.06.2019 11:00
When building customer relationships through email what should you not do? question 2 options: utilize proper grammar, spelling, and punctuation type in all capital letters use hyperlinks rather than attachments respond to all emails within 24 hours
Answers: 1
question
Computers and Technology, 23.06.2019 01:30
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) a process declaring its maximum need as maximum possible for each resource. in other words, if a resource a has 5 instances, then each process declares its maximum need as 5. (ii) a process declaring its minimum needs as maximum needs. for example, a process may need 2-5 instances of resource a. but it declares its maximum need as 2.
Answers: 3
question
Computers and Technology, 23.06.2019 03:50
Q-1 which of the following can exist as cloud-based it resources? a. physical serverb. virtual serverc. software programd. network device
Answers: 1
You know the right answer?
In this exercise, you will create a script that validates whether a credit card number contains only...
Questions
question
Mathematics, 09.06.2021 16:40
question
History, 09.06.2021 16:40
question
Mathematics, 09.06.2021 16:40
Questions on the website: 13722363