如何从php中的浏览器URL中检索id

时间:2014-06-10 13:54:15

标签: php ajax codeigniter

如何从url.user中检索id可以打开其他用户个人资料并发送消息。为此,我试图获得其他用户的身份。在我的网址ID中显示。无论如何都要从中获取身份。

我的网址 - http://test.com/test/index.php/dashboard/profile/15

id = 15

function reference_msg()
{
   alert("hi");
   $.ajax({
        type: "POST",
        data: {
            from_id:<?php echo this->session->userdata('customers_id') ?>,
            to_id :                           // here i want to get other profilers id
            subject: '<?php echo this->input->post('subject') ?>',
            message_body: '<?php echo this->input->post('body') ?>',
        },
        url: "<?php echo site_url("messages/send_via_ajax"); ?>",
        beforeSend: function() {
        },
        dataType: "html",
        async: false,
        success: function(msg) {
        }
    });
}

1 个答案:

答案 0 :(得分:0)

使用$this->uri->segment(3)

因此您的代码将更新为

to_id : <?=$this->uri->segment(3)?>

More about CI URI Class