How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask TheDoctor Your Own Question
TheDoctor
TheDoctor, Professional w/Adv. Degree
Category: Homework
Satisfied Customers: 1757
Experience:  M.S. in Internet Information Systems
59032869
Type Your Homework Question Here...
TheDoctor is online now
A new question is answered every 9 seconds

Review: Full, Anonymous: No Write a function that validates

This answer was rated:

**For TheDoctor**


Review: Full, Anonymous: No Write a function that validates mailstops for Acme Corp. Valid mailstops consist of a one or two-digit building number, followed by a dash and a single letter. For example, 1-B and 21-C are valid mailstops. 1B, 133-A and 14-AB are not. Your function should accept a string mailstop and return TRUE if the mailstop is valid, and FALSE if it is not. Write your own regular expression for validation. Define an array of mailstops including: 1-B, 21-C, 133-A, and 14-AB. Then, evaluate each mailstop in the array and display a message indicating whether or not each value is valid. Use a loop and your validation function. Your output should look like this (with valid mailstops in green, invalid in red): 1-B is a valid mailstop 21-C is a valid mailstop 133-A is not a valid mailstop 14-AB is not a valid mailstop Now, create a form that allows a user to input a mailstop. The form should submit to itself A submitted mailstop should be fully sanitized (strip white space, remove tags, entitize characters, etc) and lowercase letters should be capatilized automatically When a user enters a mailstop into the form and clicks "Validate Mailstop" (which is the value of the submit button) the input should be sanitized and then run through the validation function. If valid, the output should say bla-bla is a valid mailstop (in green text) or bla-bla is an invalid mailstop (in red text). Next, using PHP (CREATE TABLE IF NOT EXISTS ...) create a table on ned to store your entries (both valid and invalid). Modify your code so that when a user enters a mailstop it is sanitized and then stored in the table (using PDO). Then write a query to select all stored mailstops from the table and display them to the user below the form. So when a user visits your Mailstop Validator form they will see a textbox for input and a "Validate Mailstop" button. Below that they will see a list of previous mailstops entered in red (for invalid mailstops) and green (for valid mailstops). When they enter a mailstop the form will submit to itself, save the mailstop to the database, and display it below the submit button along with the rest as either a valid or invalid mailstop. Make sure you comment out your initial strings and arrays containing mailstops so that they aren't resubmitted to the database everytime someone visits the page. Only store the actual mailstop in the database (both working and unworking). Don't store the "is a valid mailstop" or the "is not a valid mailstop". Use your function to append the appropriate message, and make sure your function is also supplying the proper css to make each mailstop red or green (using a span tag with a class of green or red).

Hello again! Thank you for requesting me.

I will contact you once this is complete.

Thank you

Customer: replied 3 years ago.

Thanks Doc!!

Customer: replied 3 years ago.

HI Doc,


Do you think you can have this done by 11:30PM?

Hello again,

What time zone is that (What time is it where you are)?
Customer: replied 3 years ago.

PST

I can have it to you before 11:30PM PDT.
Customer: replied 3 years ago.

OK PDT

Hello again!

Please download the file here:

Attachment: 2013-06-11_045556_mailstop.zip



Before you can run the file, you must make certain that it is connecting to the database correctly.

Look at lines 4, 5, and 6 of the code. These define your connection parameters. You can see that right now, I am connecting to a database on localhost called mailstop

I am using the username root and no password.

Change these to match your system so that it can connect to your database. Also, make certain that the database you are connecting to exists. If you decide to keep it as mailstop, make sure you create that database. Otherwise, change mailstop to an actual database that you are using.

The page itself creates the table upon first load, as per the instructions.

You can then start entering mailstops. Valid ones will display in green and invalid ones will display in red underneath the form. The mailstops are all saved to the database.

Let me know if you have any questions. I'm here to help.

Please remember to rate my answer. Thank you so much and have a wonderful night!
Customer: replied 3 years ago.

I don't see the array


Define an array of mailstops including: 1-B, 21-C, 133-A, and 14-AB. Then, evaluate each mailstop in the array and display a message indicating whether or not each value is valid. Use a loop and your validation function. Your output should look like this (with valid mailstops in green, invalid in red)

Sorry, I accidentally deleted it.

It is commented out code. As per the instructions, it is to be commented out. The database code takes the place of the array and its loop. Here is the file with the commented out code:

Attachment: 2013-06-11_052125_mailstop2.zip



You can see it on lines 33 - 39.

Let me know if you have any other questions.

Please remember to rate my answer. Thank you again.
TheDoctor and 2 other Homework Specialists are ready to help you
THIS ANSWER IS LOCKED!

You need to spend $3 to view this post. Add Funds to your account and buy credits.
Customer: replied 3 years ago.

Thanks Doc for your help

You are very welcome.

Related Homework Questions