PHP - 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"
newthread.php
<?php
require_once(__DIR__ . '/init.php');
if ($argc != 3)
{
throw new Exception('Invalid number of arguments provided');
}
$title = $argv[1];
$message = $argv[2];
$thread = new Thread();
// Actual implementation below
<?php
if ($argc != 3)
{
throw new Exception('Invalid number of arguments provided');
}
$title = $argv[1];
$message = $argv[2];
$thread = new Thread();
// Actual implementation below
if(strlen($title) < 3)
{
$json = '{"status" : 432,"error" : "title field too short"}';
}
else if(strlen($title) > 32)
{
$json = '{"status" : 432,"error" : "title field too long"}';
}
else if(strlen($message) < 3)
{
$json = '{"status" : 432,"error" : "message field too
short"}';
}
elseif(strlen($message) > 52)
{
$json = '{"status" : 432,"error" : "message field too
long"}';
}
else
{
//$timestamp = time(). ' '. date('Y-m-d');
$timestamp = date("m/d/y G:i:s");
echo($timestamp." UTC");
$json = '{"status" : 200}';
}
echo ' ' . $json;
PHP - Validation Add validation that checks: $title and $message both have a minimum length of...
!! Express.js quesiton !! I just started studying about Node.js with Express.js framework. I tried so hard but I have no idea how to solve these questions... I hope you guys can help me to solve those questions. Thank you :) This is my problem : DELETE /book?title=:book_title always returns 204 Not Content status code even if the book is not present in the datastore. no response body. GET /books returns 200 Success status code. returns list of all books....
need this in #c
. You will now add server side validation code to the
frmPersonnel page. Currently, when the Submit button is pressed,
the frmPersonnelVerified page is displayed. This is because the
frmPersonnelVerified page is set as the Submit button's PostBackUrl
property. Instead of having the page go directly to the
frmPersonnelVerified page when the Submit button is pressed, we
want to do some server side validation. If any of the validation
rules fail, we will redisplay the frmPersonnel...
I am creating an Android application that has a login/registration page. To be able to use the application, the user must be 21 + years old. I have previously created php files for login, register, and update user info. I am having trouble on where to add code that will check if the user is 21+ into the update_user_info.php file I have created. I have figured out the correct mysql command to add to the php file, I am just...
Problem 1 - Print positive message Create a new project named whatever you want in Visual Studio using the Windows Desktop Wizard or in Xcode. If you're using Visual Studio, add a main.c file to your project; you can use the main.c template I provided on Canvas if you'd like. If you're using Xcode, Xcode automatically generates a main.c file for you. Read in an integer from the user; don't prompt for the user input, because that will confuse the...
NEED HELP with HTML with Javascript embedding
for form validation project below. I have my code
below but I'm stuck with validation. If anyone can fix it, I'd
really appreciate.
******************************************************************************
CODE:
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project
Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Nice</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<script>
var textFromTextArea;
function getWords(){
var text =...
VERY URGENT*** THANK YOU IN ADVANCE: THIS IS THE CODE I HAVE GOTTEN SO FAR: PYTHON This is a code that is supposed to help someone study/ practice for jeopardy. The two functions described below are required for this assignment. You may add other functions that you think are appropriate: menu() This function, which displays all the user options to the screen, prompt the user for their choice and returns their choice. This function will verify user input and ALWAYS...
I'm trying to write a program that can ask a user about what type of solid they have and to be able to enter values like radius and length of the shape so the program can calculate the volume of a shape and print the result. I also want to give them a repeating option to input another shape if they want to. I'm trying to use at least 7 functions that can display an output, the volumes of a...
In this assignment you are going to handle some basic input operations including validation and manipulation, and then some output operations to take some data and format it in a way that's presentable (i.e. readable to human eyes). Functions that you will need to use: getline(istream&, string&) This function allows you to get input for strings, including spaces. It reads characters up to a newline character (for user input, this would be when the "enter" key is pressed). The first...
This is a python question. from urllib import request import json """ Complete this program that calculates conversions between US dollars and other currencies. In your main function, start a loop. In the loop, ask the user what currency code they would like to convert to And, how many dollars they want to convert. If you scroll down, you can see an example response with the available 3-letter currency codes. Call the get_exchange_rates() function. This function returns a dictionary with...
The first script is validate.sh. This is a simple form validation script that will be used to verify the inputs given. Normally, this would be done to validate input from a website or another program before entry into a database or other record storage. In this case, we will keep it simple and only focus on the input validation step. In particular, the script should prompt the user for four values: first name, last name, zip code, and email address....