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;

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);


$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){

    var data = JSON.parse(response);



it always says undefined index: index

please help me with this, thank you!

Recommended Answers

All 3 Replies

i've already changed this to $index, sorry for that but it is still undefined index: index :(

$id = $_POST['index'];  

Make it a session variable, $_SESSION[xxxxxx] = "$xxxxxx"; now it will be assesible in all scripts for that users session.

$id = $_POST['index']; will only work if someone filled out a form with an index field and ended up on that page.

$id= $_REQUEST['index']; will work if someone goes to the page with a query-string parameter, such as page.php?index=123

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.