I'm trying to insert data in database after submitting form and wants to change the content of the submit button to saved. I'm able to change the contents of submit button afer submitting form but stores blank spaces in database. My form is similar to like this.

html form
<form id="yourForm">
<input type="text" name="building_length_in" id="building_length_in" placeholder="इन्च"class="form-control input-sm" value="" required>
<input type="text" name="building_breadth_ft" id="building_breadth_ft" placeholder="फीट" class="form-control input-sm" value="" required>
<input class="submitBtn" type="submit" value="Submit"/>
</form>
js
$(document).ready(function(){
$('#yourForm').submit(function(event){
$('.submitBtn').attr('value','Saved');
setTimeout(function(){
$('.submitBtn').attr('value','OK');
}, 3000);
var stuff = $('#yourForm').serialize();
jQuery.ajax({
type: 'POST',
url: 'application_save.php',
data:{
'stuff':stuff,
}
,success: function( response ){
console.log(response);debugger;
}
});
//Prevents form submission
return false;
});
});
application_save.php
<?php
require_once "conn.php";
$building_length_in=$building_breadth_ft="";
if($_SERVER["REQUEST_METHOD"] == "POST"){
$building_length_in = trim($_POST["building_length_in"]);
$building_breadth_ft = trim($_POST["building_breadth_ft"]);
mysqli_set_charset('utf8');
$sql = "INSERT INTO bps_registration_application
(building_length_in,building_breadth_ft)
VALUES (?, ?)";
if($stmt = mysqli_prepare($conn, $sql)){
mysqli_stmt_bind_param($stmt, "ss",
$building_length_in,
$building_breadth_ft);
$building_length_in= $building_length_in;
$building_breadth_ft=$building_breadth_ft;
if(mysqli_stmt_execute($stmt)){
if(!empty($reg_id)){
$success = "Submitted form successfully .";
header("location: registration_detail.php?success=$success&id=".$reg_id);
exit();
} else {
header("location: registration_detail.php");
exit();
}
}else{
echo "Something went wrong. Please try again later.";
}
}
echo $success;
mysqli_close($conn);
}
?>
console.log(stuff) contains following data .
stuff = "reg_id=74®istration_date=%E0%A5%A8%E0%A5%A6%E0%A5%AD%E0%A5%AC-%E0%A5%AA-%E0%A5%A7%E0%A5%A6&building_use_id=residential&building_category=a&building_structure_category_id=rcc&building_length_ft=4&building_length_in=4&building_breadth_ft=4&building_breadth_in=4&building_height_ft=4&building_height_in=4&building_storey=4&building_area=46666"
<br />
<b>Notice</b>: Undefined index: reg_id in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>8</b><br />
<br />
<b>Notice</b>: Undefined index: registration_date in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>9</b><br />
<br />
<b>Warning</b>: trim() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>9</b><br />
<br />
<b>Notice</b>: Undefined index: building_use_id in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>10</b><br />
<br />
<b>Warning</b>: trim() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>10</b><br />
<br />
<b>Notice</b>: Undefined index: building_category in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>11</b><br />
<br />
<b>Warning</b>: trim() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>11</b><br />
<br />
<b>Notice</b>: Undefined index: building_structure_category_id in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>12</b><br />
<br />
<b>Warning</b>: trim() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>12</b><br />
<br />
<b>Notice</b>: Undefined index: building_length_ft in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>13</b><br />
<br />
<b>Warning</b>: trim() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>13</b><br />
<br />
<b>Notice</b>: Undefined index: building_length_in in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>14</b><br />
<br />
<b>Warning</b>: trim() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>14</b><br />
<br />
<b>Notice</b>: Undefined index: building_breadth_ft in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>15</b><br />
<br />
<b>Warning</b>: trim() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>: Undefined index: building_breadth_in in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>16</b><br />
<br />
<b>Warning</b>: trim() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>16</b><br />
<br />
<b>Notice</b>: Undefined index: building_height_ft in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>17</b><br />
<br />
<b>Warning</b>: trim() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>: Undefined index: building_height_in in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>18</b><br />
<br />
<b>Warning</b>: trim() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>18</b><br />
<br />
<b>Notice</b>: Undefined index: building_storey in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>19</b><br />
<br />
<b>Warning</b>: trim() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>19</b><br />
<br />
<b>Notice</b>: Undefined index: building_area in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>20</b><br />
<br />
<b>Warning</b>: trim() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>20</b><br />
<br />
<b>Warning</b>: mysqli_set_charset() expects exactly 2 parameters, 1 given in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>21</b><br />
<br />
<b>Notice</b>: Undefined index: reg_id in <b>C:\xampp\htdocs\bps\api\application_save.php</b> on line <b>26</b><br />
{"msg":"Something went wrong. Please try again later.","reg_id":0}


stuffcontains what you expect? What does the server recieve in$_POST? Did you try and execute the sql in$sqldirectly in the database and see if that behaves the same?application_save.phpfile where is$reg_iddeclared?stuffproperty indataand just pass the serialized string ....data:stuff,