<?php
require './include/common.inc.php';

//if(!$_userid) showmessage($LANG['please_login'], $MOD['linkurl'].'login.php?forward='.urlencode($PHP_URL));
if(!$_userid) header('location:/member/login.php?forward='.urlencode($PHP_URL));

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 = $t_ans;
	$db->query("UPDATE ".TABLE_MEMBER." SET question='$s_q',answer='$myanswer' WHERE userid=$_userid");
	$db->query("UPDATE ".TABLE_MEMBER_INFO." SET idtype='$s_card',idcard='$card' WHERE userid=$_userid");

  return "true";
}

  $pwa=$db->get_one("SELECT question,answer FROM ".TABLE_MEMBER." WHERE userid=$_userid");

	$head['title'] = $LANG['member_profile_edit'];
	$head['keywords'] = $LANG['member_profile_edit'];
	$head['description'] = $LANG['member_profile_edit'];

    include template('member', 'setpwa');
?>