need mainly the php file and how to do the \"value\" portion use pregmatch to verify...

Free

60.1K

Verified Solution

Question

Programming

need mainly the php file and how to do the \"value\" portion

use pregmatch to verify proper format in the php file ifable.

Create an HTML form that will accept four fields: first name,last name, user ID, and values. Name this file userInfo.html. Thereshould be a submit and reset button on your html form. Yourinput fields for your form should be inside of a table. Thesubmit button should send the data to a php file namedupdateInfo.php. The updateInfo.php file should check the datasubmitted by the html file for proper formatting. While it isallowable that you may check input on the client side(either HTML or Javascript), you MUSTcheck for valid input on the server using PHP. (It will be easierto test your code if you don’t bother doing any checks on the HTMLside – you will have to disable the checks on your own code to testthe bad inputs).

***IMPORTANT***

Your POST variables in your HTML file must be labeled asfollows. I have written an automated script to run tests on yourcode, and it depends on the POST variables being labeled correctlywithin the HTML Form.

  1. \"first_name\"
  2. \"last_name\"
  3. \"user_id\"
  4. \"values\"

The following rules must be enforced by your PHP script aboutthe input.

  • No field is allowed to be blank.
  • Maximum length of first and last name is 20 characters.
  • The first and last names should be only made up of alphabeticalcharacters. (no numbers or symbols). Only a-z, and A-Z. Anyordering of lower/uppercase letters is acceptable.
  • User ID must be 3 lowercase letters followed by 3 numbers.Example: abc123
  • Values has a max length of 50 characters. It is a commaseparated list of values, with each value in the range 0.0 to100.0.
  • Every value must have 1 digit afterthe decimal point.
  • Every value must have 1,2, or 3digits before the decimal point (i.e. .7 is not avalid value in our system, but 0.7is valid).
  • Here is an example of input to the values field:

9.3,100.0,45.5,43.0,0.7,0.0,76.9,1.0  

If any field has invalid data, display an error message and alink back to the userInfo.html page. Do not writeinvalid data to the text file, or to the html table.Ignore all data when an entry is invalid.

If all the fields are valid, your PHP script should save thedata into a file named userInfo.txt which should have the followingformat and be sorted by “last_name”. (Note you will need to read inthe existing file’s data and add the new data to your datastructure, and sort it before you can write the new file in theproper order). Put each record on its own line. To simplify things,you can assume that Last Names are unique – i.e. you can use thelast name as a key for your associative array. (I won’t use two ofthe same last name when I test your code).

LastName--FirstName--UserID--Min,Max,Average;\n

Here is a sample record (a single line) of what should be inyour text file:

Doe--John--abc123--3.4,99.9,45.4;

You can see from this that you will need to process the inputvalues from the user to determine the min value, the max value, andthe average. To be clear, you don’t need to store all the valuesentered, just the minimum, the maximum, and the average.

Once the new data has been received, you should also display ALLdata from the text file into an HTML table. The table should besorted by last name just like the text file. After successfullydisplaying your table, create a link back to the userInfo.htmlpage. You should have 6 columns in your HTML file, with anappropriate header for each column.

Answer & Explanation Solved by verified expert
3.6 Ratings (267 Votes)

UserInfo.html

first_name:

last_name:

user_id:

values:

updateInfo.php

$first_name = $last_name= $user_id = $values =\"\";

if(!preg_match(\"/^[a-zA-Z']+)$/\",$first_name));

{

$first_nameErr= \"only letters and white spaces are allowed\";

}

if(!preg_match(\"/^[a-zA-Z']+)$/\",$last_name));

{

$last_nameErr= \"only letters and white spaces are all allowed\";

}

if(!preg_match('/^[A-Za-z][A-Za-z0-9]{5,31}$/',$user_id))

{

$user_idErr=\"Invalid\";

}

if(preg_match(^\d*\.?\d*[1-9]+\d*$)|(^[1-9]+\d*\.\d*$/',$values)

{
for($i=0;$i<100;$i++)$post_array[]=array();

{

if(isset($POST[\"values\"]))

{

$post_array[]=$_POST[\"values\"];

}

}

}

else{

$valuesErr=\"Do not write invalid data to the text file, or to the html table.\";

}

?>


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students