Question
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.
0 ) { 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 " | "; echo "
Request Student Chat Account
"; echo ""; ?>Complete the information in the form below and click Submit to create your account. All fields are required.
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started