vlad14
vlad14

Reputation: 3

GET_POST doesn't work

I have php webpage with js function:

function send_answer(){
    $.ajax({
        type: 'POST',
        url: '../path2file/file_mine.php',
        data: {dbf1:1, us:1, re:1},
        success: reload (), 
    });
    return false; 
} 

I have created php with code inside

$dbf1=$_POST['dbf1'];
$us=$_POST['us'];
$re=$_POST['re'];


"UPDATE `table` SET `app` = '$dbf1' WHERE `user_id` = '$us' AND reqn= '$re'"

DB connection and file-mine.php generally are ok. If I run php with values ($dbf1=1;..) instead of $_POST everything is ok and mysql is updated.

WHEN I activate function send_answer () it just reloading page, not UPDATE mySQL. :(

Upvotes: 0

Views: 79

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324650

This is because you are calling reload(), whereas you just want to pass reload as the callback.

success: reload, // NO () HERE!

But also...

xkcd
> xkcd

Please learn about SQL injection before it is too late. Switch to PDO now, you'll be glad you did!

Upvotes: 7

Related Questions