Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I use mysql_real_escape_string($str) in the below html/php code ? I have an example of the way I think the username should look for

How do I use mysql_real_escape_string($str) in the below html/php code ? I have an example of the way I think the username should look for example: $firstname=check_input(mysql_real_escape_string($_POST["firstname"])); Please use the escape string by inputting in the code below.

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

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

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions