开发ecshop投票送积分功能

2009-10-26 09:39 来源:www.chinab4c.com 作者:ecshop专家

1:admin/template/vote_info.htm中增加以下代码

 <tr>
    <td class="label">赠送积分:</td>
    <td>
      <input type='text' name='point' value='{$vote_arr.point}' size='40' />
    </td>
  </tr>

2:admin/vote.php中录入要送的积分。

$point = trim($_POST[point]);
        $sql = "INSERT INTO ".$ecs->table('vote')." (vote_name, start_time, end_time, can_multi, vote_count,point)
        VALUES ('$_POST[vote_name]', '$start_time', '$end_time', '$_POST[can_multi]', '0','$point')";//录入积分
        $db->query($sql);

3:admin/vote.php的update中,修改积分

 /* 更新信息 */
    $sql = "UPDATE " .$ecs->table('vote'). " SET ".
            "vote_name     = '$_POST[vote_name]', ".
            "start_time    = '$start_time', ".
            "end_time      = '$end_time', ".

   "point      = '$point', ".
            "can_multi     = '$_POST[can_multi]' ".
            "WHERE vote_id = '$_REQUEST[id]'";

 

4:前台vote.php中,在投票的时候,送积分。

//评论
 if($_SESSION['user_id']){
  $point = $db -> getOne("select point from ".$ecs->table('vote')." where vote_id = ".$vote_id);
  if($point){
    $sql1 = "update ".$ecs->table('users')." set pay_points = pay_points + $point where user_id = ".$_SESSION['user_id'];
    $db -> query($sql1);
    $string = '投票成功了,你获得了'.$point.'个积分';
    $res['message'] = $string;
  
  }else{
    $res['message'] = $_LANG['vote_success'];
  }
  
 }else{
   $res['message'] = $_LANG['vote_success'];
 }
   //评论送积分

 

来源:中国B4C电子商务