<?php

require './include/common.inc.php';
if(!$_userid) header('location:/member/login.php?forward='.urlencode($PHP_URL));
require_once HS_ROOT.'/include/field.class.php';
$field = new field($CONFIG['tablepre'].'game_info');
sajax_init();
sajax_export("doSub");
sajax_handle_client_request();
function doSub($s_q,$t_ans,$s_card,$card,$rcard)
{
global $db,$_userid;
if($s_q == '') return "<span class=font06>密码提示问题不能为空</span>";
if($t_ans == '') return "<span class=font06>密码提示答案不能为空</span>";
if($s_card == '') return "<span class=font06>证件类型不能为空</span>";
if($card == '') return "<span class=font06>证件号码不能为空</span>";
if($rcard == '') return "<span class=font06>请再确认一次证件号码</span>";
if(strlen($t_ans) >30) return "<span class=font06>密码提示答案不能超过30个字符</span>";
if(strlen($card) >30) return "<span class=font06>证件号码不能超过30个字符</span>";
if($card != $rcard) return "<span class=font06>两次证件号码输入不一致</span>";
$myanswer = md5($t_ans);
$db->query("UPDATE ".TABLE_game." SET question='$s_q',answer='$myanswer' WHERE userid=$_userid");
$db->query("UPDATE ".TABLE_game_INFO." SET idtype='$s_card',idcard='$card' WHERE userid=$_userid");
return "true";
}
$pwa=$db->get_one("SELECT question,answer FROM ".TABLE_game." WHERE userid=$_userid");
$head['title'] = $LANG['game_profile_edit'];
$head['keywords'] = $LANG['game_profile_edit'];
$head['description'] = $LANG['game_profile_edit'];
include template('game','setpwa');
?>