选择多个用户并向他们发送邀请 [英] Selecting multiple users and sending them an invite

查看:92
本文介绍了选择多个用户并向他们发送邀请的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,没有类似的帖子,我只能看到Facebook API的帖子.如果您知道某个帖子,请为我指出正确的方向,谢谢.

I apologise if there is a similar post to this that I haven't found, I can only see ones for Facebook API. If you know of a post, please do point me in the right direction, thanks.

我想做的是......

通过从列表(多选,可能使用JQuery)中选择成员并发送邀请,允许用户邀请其成员参加活动.

Allow a user to invite any member to his/her event by selecting them from a list (Multiple selection, possibly with JQuery) and sending the invite.

我了解必须要做的事情背后的理论...

  1. 在表中动态显示了用户列表(我知道该怎么做)

允许选择每个用户. (不知道如何在JQuery中做到这一点)

Allow each user to be selected. (Don't know how to do that in JQuery)

然后,当您单击某个用户时,其用户ID将放入数组中 某种(可能需要帮助)

Then, when you click on a user, their user id is put into an array of some kind (Might need help with that)

然后,在提交邀请按钮时,将id放入名为 邀请以及被邀请参加的活动的ID. (我知道该怎么做)

Then when the invite button is submitted, the ids are put into a database table called invitations along with the id of the event they are being invited to. (I know how to do that)

我在jquery.com上进行了查看,但是由于我绝不是专家,因此我不确定自己需要做什么.如果您需要了解其他任何信息,请询问.

I've had a look on jquery.com but as I'm not by any means an expert at it I'm not really sure on what I need to do. If you need to know anything else, please ask.

非常感谢您的帮助.

应该添加,我的数据库是MySQL,我正在用PHP编码.

edit: Should probably add, my database is MySQL and I'm coding in PHP.

推荐答案

创建一个表单元素,将表格放在表单中.在每个表行td上创建复选框.复选框的值是用户ID的值.

Create a form element, put your table within the form. Create checkboxes on each table row td. Checkbox value is that of the user's ID.

使用Jquery对复选框进行序列化,然后将序列化的表单提交给php脚本以完成后端的工作...

use Jquery to serialize the checkboxes and submit a serialized form to a php script to do the backend leg work...

  $('#submit-form-button').click(function(){
    var checkboxes = $('.checkboxes').serialize();
    $.ajax({
      url: 'processInvites.php',
      dataType: "json",
      data: {checkBoxes: checkboxes},
      success: function(data){
        console.log("Form was successful");
      },
      error: function(data){
        console.log("Form was a failure");
      }
    });
  });

使用PHP爆炸序列化的数组. 应该注意,您可以在php手册中引用urldecode(),并且在手册底部,在注释之前有一个类似的声明.

Use PHP to explode the serialized array.. Should note you can reference urldecode() in the php manual and it has a similar statement at the bottom of the manual, just before the comments.. http://php.net/manual/en/function.urldecode.php

$c = explode('&', $_POST['checkBoxes']);
$i = 0;
while ($i < count($c)){
  $b = explode('=', $c[$i]);
  $checkBox[] = urldecode($b[1]);
  $i++;
}

并验证它是否存在于数据库中.

and verify that it exists in the db..

$listOfUsers = //SQL HERE TO GET ARRAY OF USERS IDs IN KEY => VALUE FORM.

foreach ($checkBox as $c){
  if(in_array($c, $listOfUsers){
    //INSERT USER ID IN INVITATIONS TABLE
    //SQL HERE, MAKE SURE TO XSS FILTER YOUR POST INPUTS
  }else{
    //User isnt in database, do something else. 
    // don't return false or fail because you want to continue processing
    // write to a log file?
  }
}

我还没有测试过,但是对于选择类别"列表并从db中拉出与该类别ID相等的行的不同应用程序,我使用了完全相同的概念.

I have not tested this, but i use the exact same concept for a different application of selecting a list of "Categories" and pulling back rows from db that are equal to that categories ID..

这篇关于选择多个用户并向他们发送邀请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆