Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions