Question: Testing for SQL Injection, how can I eliminate the boolean conditions [ZAP' AND '1'='1] and [ZAP' AND '1'='2] from occuring in the below code? Please

Testing for SQL Injection, how can I eliminate the boolean conditions [ZAP' AND '1'='1] and [ZAP' AND '1'='2] from occuring in the below code? Please explain the way you have changed the code to eliminate the boolean conditions.

Create Student

0 ) { echo "

"; echo "
"; echo ""; echo ""; echo ""; echo "
"; echo "

Warning! Form Entry Errors Exist.

"; echo "

Please revise based on the following issues and submit again.

"; echo "
    ";

    foreach ($messages as $m) { echo "

  1. $m
  2. "; } echo "
"; echo "
"; echo "

"; } // Assign post values if exist $firstname=""; $lastname=""; $wsname=""; $email=""; if (isset($_POST["firstname"])) $firstname=check_input($_POST["firstname"]); if (isset($_POST["lastname"])) $lastname=check_input($_POST["lastname"]); if (isset($_POST["wsname"])) $wsname=check_input($_POST["wsname"]); if (isset($_POST["email"])) $email=check_input($_POST["email"]); echo "

"; echo "

Request Student Chat Account

"; echo "

"; ?>
Complete the information in the form below and click Submit to create your account. All fields are required.
Firstname:
Lastname:
WebTycho username:
Email:

function validate_form() { require_once('Includes/Utils.php'); require_once('Includes/FormObjects.php'); require_once('Includes/SQLFunctions.php'); $messages = array(); $redisplay = false; // Assign values $firstname = check_input($_POST["firstname"]); $lastname = check_input($_POST["lastname"]); $wsname = check_input($_POST["wsname"]); $email = check_input($_POST["email"]); // Just check for null values and email format if (strlen($firstname)==0) { $redisplay = true; $messages[]="Please enter your Firstname."; } if (strlen($lastname)==0) { $redisplay = true; $messages[]="Please enter your lastname."; } if (strlen($wsname)==0) { $redisplay = true; $messages[]="Please enter your WebTycho username."; } if (strlen($email)==0) { $redisplay = true; $messages[]="Please enter your Email address."; } if ($redisplay) { show_form($messages); } else { // Show the page header include('Includes/Header.php'); $student = new StudentClass($firstname,$lastname,$email,$wsname); $count = countStudent($student); // Check for accounts that already exist and Do insert if ($count==0) { $res = insertStudent($student); echo "

Welcome to the CS Chat Program!

"; echo "

click here to login

";

} else { echo "

A student account with that WenTycho username already exists.

"; echo "

Please login using $wsname

"; } } }

?>

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!