Jump to content

How to escape Ajax Request in PHP


kwame123

Recommended Posts

<?php
include($_SERVER['DOCUMENT_ROOT']."/ext/inc/header.php");
$q = $_REQUEST["q"];
$username = mysqli_real_escape_string($conn, $q);
//echo $username."test<Br>";
echo $q;

mysqli_close($conn);
?>

$q is the string that is being typed in an input box on another page.

 

$username wont echo but $q will.

how to escape $q so i can use it in database quires? 

Link to comment
Share on other sites

Perhaps it doesn't echo because you commented out the line.

 

Don't escape the variable, use prepared statements instead, binding the variable as a parameter

i commented out the line because the line didnt work.

 

and okay i will look into it

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.