Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

<html> <header></header> <body> <form method=\"post\"action=\"diplay_info.php\">

ID: 3675152 • Letter: #

Question

<html>

<header></header>

<body>

<form method="post"action="diplay_info.php">

<p>Your name:<inputtype="text" name="name"/></p>

there are for more lines like this, address, city, state, and zicode

<input type="submit" name="submit" value="Submit"/>

</body>

</html

Create a web form just like in part 1 with the same fields.

Create a script that uses isset() and empty() methods to ensure that all of the fields are filled in by the user. If any of the fields are blank or missing, echo the following message to the user:

“Please be sure to complete all of the fields – use the back button to return to the form”

Explanation / Answer

if(!isset($_POST['submit'])) exit(); $vars = array('login', 'password','confirm', 'name', 'email', 'phone'); $verified = TRUE; foreach($vars as $v) { if(!isset($_POST[$v]) || empty($_POST[$v])) { $verified = FALSE; } } if(!$verified) { exit(); } public function areNull() { if (func_num_args() == 0) return false; $arguments = func_get_args(); foreach ($arguments as $argument): if (is_null($argument)) return true; endforeach; return false; } $var = areNull("username", "password", "etc"); if( isset( $_POST['login'] ) && strlen( $_POST['login'] )) { // valid $_POST['login'] is set and its value is greater than zero } else { //error either $_POST['login'] is not set or $_POST['login'] is empty form field } $missing = array(); foreach ($_POST as $key => $value) { if ($value == "") { array_push($missing, $key);}} if (count($missing) > 0) { echo "Required fields found empty: "; foreach ($missing as $k => $v) { echo $v." ";} } else { unset($missing); // do your stuff here with the $_POST } //function to make sure that all of the required fields of a post are sent. Returns True for error and False for NO error //accepts a string that is then parsed by "," into an array. The array is then checked for empty values. function errorPOSTEmpty($stringOfFields) { $error = false; if(!empty($stringOfFields)) { // Required field names $required = explode(',',$stringOfFields); // Loop over field names foreach($required as $field) { // Make sure each one exists and is not empty if (empty($_POST[$field])) { $error = true; // No need to continue loop if 1 is found. break; } } } return $error; } $postError = errorPOSTEmpty('login,password,confirm,name,phone,email'); if ($postError === true) { ...error code... } else { ...vars set goto POSTing code... }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote