我的意思是 不让这段代码验证:用户名和邮件地址是否匹配 输入邮箱号直接发送。用户名有没有都可以/* 发送密码修改确认邮件 */
elseif ($action == 'send_pwd_email')
{
include_once(ROOT_PATH . 'includes/lib_passport.php'); /* 初始化会员用户名和邮件地址 */
$user_name = !empty($_POST['user_name']) ? trim($_POST['user_name']) : '';
$email = !empty($_POST['email']) ? trim($_POST['email']) : ''; //用户名和邮件地址是否匹配
$user_info = $user->get_user_info($user_name); if ($user_info && $user_info['email'] == $email)
{
//生成code
//$code = md5($user_info[0] . $user_info[1]); $code = md5($user_info['user_id'] . $_CFG['hash_code'] . $user_info['reg_time']);
//发送邮件的函数
if (send_pwd_email($user_info['user_id'], $user_name, $email, $code))
{
show_message($_LANG['send_success'] . $email, $_LANG['back_home_lnk'], './', 'info');
}
else
{
//发送邮件出错
show_message($_LANG['fail_send_password'], $_LANG['back_page_up'], './', 'info');
}
}
else
{
//用户名与邮件地址不匹配
show_message($_LANG['username_no_email'], $_LANG['back_page_up'], '', 'info');
}
}
elseif ($action == 'send_pwd_email')
{
include_once(ROOT_PATH . 'includes/lib_passport.php'); /* 初始化会员用户名和邮件地址 */
$user_name = !empty($_POST['user_name']) ? trim($_POST['user_name']) : '';
$email = !empty($_POST['email']) ? trim($_POST['email']) : ''; //用户名和邮件地址是否匹配
$user_info = $user->get_user_info($user_name); if ($user_info && $user_info['email'] == $email)
{
//生成code
//$code = md5($user_info[0] . $user_info[1]); $code = md5($user_info['user_id'] . $_CFG['hash_code'] . $user_info['reg_time']);
//发送邮件的函数
if (send_pwd_email($user_info['user_id'], $user_name, $email, $code))
{
show_message($_LANG['send_success'] . $email, $_LANG['back_home_lnk'], './', 'info');
}
else
{
//发送邮件出错
show_message($_LANG['fail_send_password'], $_LANG['back_page_up'], './', 'info');
}
}
else
{
//用户名与邮件地址不匹配
show_message($_LANG['username_no_email'], $_LANG['back_page_up'], '', 'info');
}
}
不要那些验证。直接可以发送?
那么/* 发送密码修改确认邮件 */
elseif ($action == 'send_pwd_email')
{
include_once(ROOT_PATH . 'includes/lib_passport.php');
$user_name=$_POST['user_name'];
$user_info = $user->get_user_info($user_name);
$code = md5($user_info['user_id'] . $_CFG['hash_code'] . $user_info['reg_time']); if (send_pwd_email($user_info['user_id'], $user_name, $email, $code))
{
show_message($_LANG['send_success'] . $email, $_LANG['back_home_lnk'], './', 'info');
}
else
{
//发送邮件出错
show_message($_LANG['fail_send_password'], $_LANG['back_page_up'], './', 'info');
}
}
$email =$_POST['email'];
加到 $user_name=....下面
ECSHOP(商城系统)http://www.utoyu.com/user.php?act=get_password就和这个一样 输入用户名 和邮箱 如果是正确的话他会发送找回密码的邮件,我的意思是只要输入邮箱他就能发送邮件不需要验证用户名和邮箱存在还是不存在user.php里的代码elseif ($action == 'send_pwd_email')
{
include_once(ROOT_PATH . 'includes/lib_passport.php'); /* 初始化会员用户名和邮件地址 */
$user_name = !empty($_POST['user_name']) ? trim($_POST['user_name']) : '';
$email = !empty($_POST['email']) ? trim($_POST['email']) : ''; //用户名和邮件地址是否匹配
$user_info = $user->get_user_info($user_name); if ($user_info && $user_info['email'] == $email)
{
//生成code
//$code = md5($user_info[0] . $user_info[1]); $code = md5($user_info['user_id'] . $_CFG['hash_code'] . $user_info['reg_time']);
//发送邮件的函数
if (send_pwd_email($user_info['user_id'], $user_name, $email, $code))
{
show_message($_LANG['send_success'] . $email, $_LANG['back_home_lnk'], './', 'info');
}
else
{
//发送邮件出错
show_message($_LANG['fail_send_password'], $_LANG['back_page_up'], './', 'info');
}
}
else
{
//用户名与邮件地址不匹配
show_message($_LANG['username_no_email'], $_LANG['back_page_up'], '', 'info');
}
}
* 会员找回密码时,对输入的用户名和邮件地址匹配
*
* @access public
* @param string $user_name 用户帐号
* @param string $email 用户Email
*
* @return boolen
*/
function check_userinfo($user_name, $email)
{
if (empty($user_name) || empty($email))
{
ecs_header("Location: user.php?act=get_password\n"); exit;
} /* 检测用户名和邮件地址是否匹配 */
$user_info = $GLOBALS['user']->check_pwd_info($user_name, $email);
if (!empty($user_info))
{
return $user_info;
}
else
{
return false;
}
}/**
* 用户进行密码找回操作时,发送一封确认邮件
*
* @access public
* @param string $uid 用户ID
* @param string $user_name 用户帐号
* @param string $email 用户Email
* @param string $code key
*
* @return boolen $result;
*/
function send_pwd_email($uid, $user_name, $email, $code)
{
if (empty($uid) || empty($user_name) || empty($email) || empty($code))
{
ecs_header("Location: user.php?act=get_password\n"); exit;
} /* 设置重置邮件模板所需要的内容信息 */
$template = get_mail_template('send_password');
$reset_email = $GLOBALS['ecs']->url() . 'user.php?act=get_password&uid=' . $uid . '&code=' . $code; $GLOBALS['smarty']->assign('user_name', $user_name);
$GLOBALS['smarty']->assign('reset_email', $reset_email);
$GLOBALS['smarty']->assign('shop_name', $GLOBALS['_CFG']['shop_name']);
$GLOBALS['smarty']->assign('send_date', date('Y-m-d'));
$GLOBALS['smarty']->assign('sent_date', date('Y-m-d')); $content = $GLOBALS['smarty']->fetch('str:' . $template['template_content']); /* 发送确认重置密码的确认邮件 */
if (send_mail($user_name, $email, $template['template_subject'], $content, $template['is_html']))
{
return true;
}
else
{
return false;
}
}/**
* 发送激活验证邮件
*
* @access public
* @param int $user_id 用户ID
*
* @return boolen
*/
function send_regiter_hash ($user_id)
{
/* 设置验证邮件模板所需要的内容信息 */
$template = get_mail_template('register_validate');
$hash = register_hash('encode', $user_id);
$validate_email = $GLOBALS['ecs']->url() . 'user.php?act=validate_email&hash=' . $hash; $sql = "SELECT user_name, email FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = '$user_id'";
$row = $GLOBALS['db']->getRow($sql); $GLOBALS['smarty']->assign('user_name', $row['user_name']);
$GLOBALS['smarty']->assign('validate_email', $validate_email);
$GLOBALS['smarty']->assign('shop_name', $GLOBALS['_CFG']['shop_name']);
$GLOBALS['smarty']->assign('send_date', date($GLOBALS['_CFG']['date_format'])); $content = $GLOBALS['smarty']->fetch('str:' . $template['template_content']); /* 发送确认重置密码的确认邮件 */
if (send_mail($row['user_name'], $row['email'], $template['template_subject'], $content, $template['is_html']))
{
return true;
}
else
{
return false;
}
}/**
* 生成邮件验证hash
*
* @access public
* @param
*
* @return void
*/
function register_hash ($operation, $key)
{
if ($operation == 'encode')
{
$user_id = intval($key);
$sql = "SELECT reg_time ".
" FROM " . $GLOBALS['ecs'] ->table('users').
" WHERE user_id = '$user_id' LIMIT 1";
$reg_time = $GLOBALS['db']->getOne($sql); $hash = substr(md5($user_id . $GLOBALS['_CFG']['hash_code'] . $reg_time), 16, 4); return base64_encode($user_id . ',' . $hash);
}
else
{
$hash = base64_decode(trim($key));
$row = explode(',', $hash);
if (count($row) != 2)
{
return 0;
}
$user_id = intval($row[0]);
$salt = trim($row[1]); if ($user_id <= 0 || strlen($salt) != 4)
{
return 0;
} $sql = "SELECT reg_time ".
" FROM " . $GLOBALS['ecs'] ->table('users').
" WHERE user_id = '$user_id' LIMIT 1";
$reg_time = $GLOBALS['db']->getOne($sql); $pre_salt = substr(md5($user_id . $GLOBALS['_CFG']['hash_code'] . $reg_time), 16, 4); if ($pre_salt == $salt)
{
return $user_id;
}
else
{
return 0;
}
}
}
<div class="usBox_2 clearfix">
<form action="user.php" method="post" name="getPassword" onsubmit="return submitPwdInfo();">
<br />
<table width="70%" border="0" align="center">
<tr>
<td colspan="2" align="center"><strong>{$lang.username_and_email}</strong></td>
</tr>
<tr>
<td width="29%" align="right">{$lang.username}</td>
<td width="61%"><input name="user_name" type="text" size="30" class="inputBg" /></td>
</tr>
<tr>
<td align="right">{$lang.email}</td>
<td><input name="email" type="text" size="30" class="inputBg" /></td>
</tr>
<tr>
<td></td>
<td><input type="hidden" name="act" value="send_pwd_email" />
<input type="submit" name="submit" value="{$lang.submit}" class="bnt_blue" style="border:none;" />
<input name="button" type="button" onclick="history.back()" value="{$lang.back_page_up}" style="border:none;" class="bnt_blue_1" />
</td>
</tr>
</table>