my system is savings account system, in which i tried to redirect to another php page with the same user id that i want to manage his/her account yet , when i deposit all of the users have the same fk,
here is my code, hope you help me with this, thank you in advance.
this is the query part;
<?php
session_start();
include "connect.php";
$id = $_POST['index'];
$sql = "SELECT * FROM `client_accounts` as ca,`ct_trans` as ct WHERE `ca`.`client_id` = `ct`.`ct_client_id` AND `ct`.`ct_client_id` = '$index';";
$query = $db->query($sql);
$arr;
$msg = [];
if($query-> num_rows > 0){
while ($row = $query->fetch_assoc()){
$arr['id'] = $row['ct_client_id'];
}
$msg['status'] = true;
$msg['data'] = $arr;
}else {
$msg['status'] = false;
$msg['message'] = "Failed";
}
echo json_encode($msg);
?>
this is the javascript part or the jquery;
function transaction(i){
$.post("tran.php",{"index":i},function(response){
var data = JSON.parse(response);
if(data.status){
$("#request").html(data.message);
window.location="transaction.php";
}else{
$('#request').text(data.message);
}
})
}
it always says undefined index: index
please help me with this, thank you!