Im trying to insert a base64 image string into my database, Iv'e been messing around with this for a few hours now, tried various different methods and for some reason I can't seem to get it to post the data to my php script.
app.js
saveButton.addEventListener("click", function (event) {
if (signaturePad.isEmpty()) {
alert("Please provide signature first.");
} else {
var basevalue = signaturePad.toDataURL();
$.ajax({
type: "POST",
url: "insert.php",
data: { basevle: basevalue }
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
}
});
insert.php
basevalue = $_POST['basevle'];
try {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("INSERT INTO signatures VALUES (0,:sigbase)");
$stmt->bindParam(':sigbase', $signature);
$signature = $basevalue);
$stmt->execute();
echo "added";
}
catch(PDOException $e)
{
echo "Error: " . $e->getMessage();
}
$conn = null;
I know there's nothing wrong with the php file as Iv'e tested it and it's inserting values, it seems to be the app.js not sending the post data
Anyone got any thoughts on what could be causing the issue ?