ecshop留言板添加一项必填项-联系人,并且留言后,联系人会在后台显示出来

最好有图文教程,或者能一步一步教我做,我知道这队懂php的来说不算难!~希望有位比较耐心的高手教教我~本人主要是网页设计,php后台语言不懂!~虽然没有分,但是以后有什么... 最好有图文教程,或者能一步一步教我做,我知道这队懂php的来说不算难!~
希望有位比较耐心的高手教教我~本人主要是网页设计,php后台语言不懂!~
虽然没有分,但是以后有什么需要帮助的地方,一句话过来就可以了!
红色框部分是添加的必填项
展开
 我来答
北漂燕郊杨哥
2011-05-17 · TA获得超过221个赞
知道小有建树答主
回答量:414
采纳率:0%
帮助的人:527万
展开全部
ecshop留言板添加一项必填项-联系人
一、首先要为你的数据库的ecs_comment增加一个字段以存储联系人姓名:
可以直接在后台-->数据库管理--->SQL查询里里直接执行以下sql语句:
alter table ecs_comment add contact varchar(60) not null default '';
此处注意,这条sql语句中的表前缀ecs_要和你网站的前缀一致,不然会报错,如果你不知道你ecshop网站的数据表前缀
,请看这里

二、修改评论提交表单增加联系人表单项
打开你网站的themes文件夹,找到你的模板风格,进入里面,找到message_board.dwt,在
<tr>
<td align="right">{$lang.email}</td>
<td><input name="user_email" type="text" class="inputBg" size="20" value="{$smarty.session.email|escape}" /></td>
</tr>
这段代码的下方增加

<tr>
<td align="right">联系人</td>
<td><input name="contact" type="text" class="inputBg" size="20" value="" /></td>
</tr>
然后修改提交评论的js函数为
/**
* 提交留言信息
*/
function submitMsgBoard(frm)
{
var msg = new Object;

msg.user_email = frm.elements['user_email'].value;
msg.contact = frm.elements['contact'].value;
msg.msg_title = frm.elements['msg_title'].value;
msg.msg_content = frm.elements['msg_content'].value;
msg.captcha = frm.elements['captcha'] ? frm.elements['captcha'].value : '';

var msg_err = '';

if (msg.user_email.length > 0)
{
if (!(Utils.isEmail(msg.user_email)))
{
msg_err += msg_error_email + '\n';
}
}
else
{
msg_err += msg_empty_email + '\n';
}
if (msg.contact.length == 0)
{
msg_err += '联系人不能为空\n';
}
if (msg.msg_title.length == 0)
{
msg_err += msg_title_empty + '\n';
}
if (frm.elements['captcha'] && msg.captcha.length==0)
{
msg_err += msg_captcha_empty + '\n'
}
if (msg.msg_content.length == 0)
{
msg_err += msg_content_empty + '\n'
}
if (msg.msg_title.length > 200)
{
msg_err += msg_title_limit + '\n';
}

if (msg_err.length > 0)
{
alert(msg_err);
return false;
}
else
{
return true;
}
}

三、修改处理评论提交的message.php
if ($action == 'act_add_message')
{
include_once(ROOT_PATH . 'includes/lib_clips.php');

/* 验证码防止灌水刷屏 */
if ((intval($_CFG['captcha']) & CAPTCHA_MESSAGE) && gd_version() > 0)
{
include_once('includes/cls_captcha.php');
$validator = new captcha();
if (!$validator->check_word($_POST['captcha']))
{
show_message($_LANG['invalid_captcha']);
}
}
else
{
/* 没有验证码时,用时间来限制机器人发帖或恶意发评论 */
if (!isset($_SESSION['send_time']))
{
$_SESSION['send_time'] = 0;
}

$cur_time = gmtime();
if (($cur_time - $_SESSION['send_time']) < 30) // 小于30秒禁止发评论
{
show_message($_LANG['cmt_spam_warning']);
}
}
$user_name = '';
if (empty($_POST['anonymous']) && !empty($_SESSION['user_name']))
{
$user_name = $_SESSION['user_name'];
}
elseif (!empty($_POST['anonymous']) && !isset($_POST['user_name']))
{
$user_name = $_LANG['anonymous'];
}
elseif (empty($_POST['user_name']))
{
$user_name = $_LANG['anonymous'];
}
else
{
$user_name = htmlspecialchars(trim($_POST['user_name']));
}

$user_id = !empty($_SESSION['user_id']) ? $_SESSION['user_id'] : 0;
$message = array(
'user_id' => $user_id,
'user_name' => $user_name,
'user_email' => isset($_POST['user_email']) ? htmlspecialchars(trim($_POST['user_email'])) : '',
'contact' => isset($_POST['user_email']) ? htmlspecialchars(trim($_POST['contact'])) : '',

'msg_type' => isset($_POST['msg_type']) ? intval($_POST['msg_type']) : 0,
'msg_title' => isset($_POST['msg_title']) ? trim($_POST['msg_title']) : '',
'msg_content' => isset($_POST['msg_content']) ? trim($_POST['msg_content']) : '',
'order_id' => 0,
'msg_area' => 1,
'upload' => array()
);

if (add_message($message))
{
if (intval($_CFG['captcha']) & CAPTCHA_MESSAGE)
{
unset($_SESSION[$validator->session_word]);
}
else
{
$_SESSION['send_time'] = $cur_time;
}
$msg_info = $_CFG['message_check'] ? $_LANG['message_submit_wait'] : $_LANG['message_submit_done'];
show_message($msg_info, $_LANG['message_list_lnk'], 'message.php');
}
else
{
$err->show($_LANG['message_list_lnk'], 'message.php');
}
}

四、增加后台显示联系人

a、打开admin/user_msg.php,把
/**
*
*
* @access public
* @param
*
* @return void
*/
function msg_list()
{
/* 过滤条件 */
$filter['keywords'] = empty($_REQUEST['keywords']) ? '' : trim($_REQUEST['keywords']);
if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1)
{
$filter['keywords'] = json_str_iconv($filter['keywords']);
}
$filter['msg_type'] = isset($_REQUEST['msg_type']) ? intval($_REQUEST['msg_type']) : -1;
$filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'f.msg_id' : trim($_REQUEST['sort_by']);
$filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);

$where = '';
if ($filter['keywords'])
{
$where .= " AND f.msg_title LIKE '%" . mysql_like_quote($filter['keywords']) . "%' ";
}
if ($filter['msg_type'] != -1)
{
$where .= " AND f.msg_type = '$filter[msg_type]' ";
}

$sql = "SELECT count(*) FROM " .$GLOBALS['ecs']->table('feedback'). " AS f" .
" WHERE parent_id = '0' " . $where;
$filter['record_count'] = $GLOBALS['db']->getOne($sql);

/* 分页大小 */
$filter = page_and_size($filter);

$sql = "SELECT f.msg_id, f.user_name, f.contact, f.msg_title, f.msg_type, f.order_id, f.msg_status, f.msg_time, f.msg_area, COUNT(r.msg_id) AS reply " .
"FROM " . $GLOBALS['ecs']->table('feedback') . " AS f ".
"LEFT JOIN " . $GLOBALS['ecs']->table('feedback') . " AS r ON r.parent_id=f.msg_id ".
"WHERE f.parent_id = 0 $where " .
"GROUP BY f.msg_id ".
"ORDER by $filter[sort_by] $filter[sort_order] ".
"LIMIT " . $filter['start'] . ', ' . $filter['page_size'];

$msg_list = $GLOBALS['db']->getAll($sql);
foreach ($msg_list AS $key => $value)
{ if($value['order_id'] > 0)
{
$msg_list[$key]['order_sn'] = $GLOBALS['db']->getOne("SELECT order_sn FROM " . $GLOBALS['ecs']->table('order_info') ." WHERE order_id= " .$value['order_id']);
}
$msg_list[$key]['msg_time'] = local_date($GLOBALS['_CFG']['time_format'], $value['msg_time']);
$msg_list[$key]['msg_type'] = $GLOBALS['_LANG']['type'][$value['msg_type']];
}
$filter['keywords'] = stripslashes($filter['keywords']);
$arr = array('msg_list' => $msg_list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);

return $arr;
}

b、打开admin/templates/msg_list.htm 把
<td align="center">{$msg.user_name}</td>
改成
<td align="center">{$msg.user_name}<br />{$msg.contact}</td>

参考资料: http://ecshop.topit.cn/ecshop-tutorial/ecshop_liuyanbai_zhenjialianxiren-94.html

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式