How to pass variable from JavaScript to PHP using jQuery POST

后端 未结 2 2024
萌比男神i
萌比男神i 2021-01-25 22:33

I am passing the variable sessionnum from the following Javascript function in the page chat.php:

$(document).ready(function(){

        timestamp =         


        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-25 22:42

    It would appear as though you're relying on register_globals, and referencing what would be the POST variable in PHP, instead of referencing the $_POST superglobal index, e.g.

    if ( $_POST['action'] == 'postmsg' ) {
        $name= mysql_real_escape_string( trim( $_POST['name'] ) );
        // query using $name reference
    }
    

    As an aside, you should really reconsider allowing the use of the tablename in the client side code.

提交回复
热议问题