Question: PHP - Thread Validation Add validation that checks: $title and $message both have a minimum length of 3. title has a maximum length of 32

PHP - Thread Validation

Add validation that checks:

$title and $message both have a minimum length of 3.

title has a maximum length of 32 characters.

$message has a maximum length of 52 characters.

If any of the three validation rules fail, print a status of 432 and an error message of what is wrong with the user input. The JSON response should look like:

{status: 432, error: title field is too short} 

If the user submitted a successful post, save the record using the provided Thread class. Set the timeposted set to when the item was submitted. Make the thread visible as soon as its submitted. Print a status code of 200. The JSON response should look like:

{status: 200} 

Add your code to newthread.php. Test your script by running:

php newthread.php "My Title Here" "My Message here" 

Given:

newthread.php

                                            

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!