Can we assign $_POST[“some value”] to a $var using php? like $transName = htmlspecialchars($_POST[“transName”]);

enter image description hereIn android onclick I am passing a string to php using httpurlconnection and with that string I am trying to make a query that will select only those values which match the string?

<?php
require "init.php";
$transName = htmlspecialchars($_POST["transName"]);
$sql_query = "select * from trans_info where transName like '$transName';";
$res= mysqli_query($con,$sql_query);
$result= array();
while($row = mysqli_fetch_array($res))
{
        array_push($result,
        array('transName'=>$row[0],
              'transGM'=>$row[1],
              'transGR'=>$row[2],
              'transAmt'=>$row[3]
                  ));
}
echo json_encode(array("result"=>$result));
mysqli_close($con);
?>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s