JAjax function to copy a string into a mysql record

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
dgasparin
Veteran Member
Posts: 31
Joined: 2020-03-26 13:03

Re: JAjax function to copy a string into a mysql record

Post by dgasparin » 2020-04-06 10:33

Dear friend now is working thank you so much.
These are the two files:
patient-dv.js
unction copy() {
var wid=$j('#wid').val();
$j.ajax({
type : 'POST',
url : 'hooks/reqhr.php',
data: {wid: wid},
success: function(data) {
alert(data);}
});
}

$j(function() {
$j(
'<div class="btn-group-vertical btn-group-lg vspacer-lg" style="width: 100%;">' +
'<button id="bc" onclick="copy()" type="button" class="btn btn-primary btn-lg">' +
'<i class="glyphicon glyphicon-list-alt"></i> Check Heart Rate' +
'</button>' +
'</div>'
).appendTo('.detail_view .btn-toolbar');
});

this is the PHP
<?php
$code=",080373#";
$codeheart="PXL,";
$servername = "localhost";
$database = "cnms";
$username = "nms";
$password = "";
$wid = $_POST['wid'];
$final = "$codeheart$wid$code";
echo $codeheart."".$wid."".$code;
// Create connection

$conn = mysqli_connect($servername, $username, $password, $database);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO request (code) VALUES ('$final')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>
Thank you so much
You were very kind

Post Reply