Here is my query code, How can write same code in the prepare statement php.
<?php
header('Content-type : bitmap; charset=utf-8');
if($_SERVER['REQUEST_METHOD']=='POST'){
$encoded_string = $_POST['image'];
$name = $_POST['name'];
require_once('dbconnect.php');
$sql ="SELECT id FROM images ORDER BY id ASC";
$res = mysqli_query($con,$sql);
$id = 0;
while($row = mysqli_fetch_array($res)){
$id = $row['id'];
}
$path = "uploadedimages/$id.jpg";
$actualpath = "http://plantnow.net16.net/$path";
$query = "INSERT INTO images(image, name) values ('$actualpath','$name')";
if(mysqli_query($con,$query)){
file_put_contents($path,base64_decode($encoded_string));
echo "Successfully Uploaded";
}
mysqli_close($con);
}
else{
echo "Error";
}
?>
1 Answer(s)