台灣最大程式設計社群網站
線上人數
1553
 
會員總數:246274
討論主題:189809
歡迎您免費加入會員
討論區列表 >> PHP >> email尚未連結認證,帳號密碼可以先登入了??
[]  
[我要回覆]
1
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
email尚未連結認證,帳號密碼可以先登入了??
價值 : 100 QP  點閱數:2322 回應數:5
樓主

yes
門外漢
0 4
165 29
發送站內信

請高手幫幫小弟一下!!
目前作一網頁,新加入會員之後,
要先去email信箱收信,作認證連結之後,
才可以用申請的帳號密碼作登入,
但我目前狀況為:
email尚未連結認證,帳號密碼就可以先登入了!!
欄位Auth 在email連結前後,是有更改動作,
這部份沒問題,請幫忙看看下面的程式囉~TKS!!

<?php require_once('Connections/okay.php'); ?>
<?php require_once("escape_to_php.php"); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}

// 記住使用者填入的資料
if (!isset($_COOKIE['MY_username']))
setcookie("MY_username", "", time() + 3600);
if (!isset($_COOKIE['MY_password']))
setcookie("MY_password", "", time() + 3600);
if (!isset($_COOKIE['MY_name']))
setcookie("MY_name", "", time() + 3600);
if (!isset($_COOKIE['MY_sex']))
setcookie("MY_sex", "", time() + 3600);
if (!isset($_COOKIE['MY_year']))
setcookie("MY_year", "", time() + 3600);
if (!isset($_COOKIE['MY_month']))
setcookie("MY_month", "", time() + 3600);
if (!isset($_COOKIE['MY_day']))
setcookie("MY_day", "", time() + 3600);
if (!isset($_COOKIE['MY_email']))
setcookie("MY_email", "", time() + 3600);
if (!isset($_COOKIE['MY_phone']))
setcookie("MY_phone", "", time() + 3600);
if (!isset($_COOKIE['MY_address']))
setcookie("MY_address", "", time() + 3600);
if (!isset($_COOKIE['MY_uniform']))
setcookie("MY_uniform", "", time() + 3600);
if (!isset($_COOKIE['MY_unititle']))
setcookie("MY_unititle", "", time() + 3600);
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="member_new_3.php";
$loginUsername = $_POST['username'];
$LoginRS__query = sprintf("SELECT username FROM member WHERE username=%s", GetSQLValueString($loginUsername, "text"));
mysql_select_db($database_okay, $okay);
$LoginRS=mysql_query($LoginRS__query, $okay) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);

//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

// 設定 birthday 欄位
$_POST['birthday'] = $_POST['year'] . '-' . $_POST['month'] . '-' . $_POST['day'];


if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "member_new_form")) {
$insertSQL = sprintf("INSERT INTO member (username, password, Auth, name, sex, birthday, email, phone, address, uniform, unititle, userlevel) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['Auth'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['sex'], "text"),
GetSQLValueString($_POST['birthday'], "date"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['phone'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['uniform'], "text"),
GetSQLValueString($_POST['unititle'], "text"),
GetSQLValueString($_POST['userlevel'], "int"));

mysql_select_db($database_okay, $okay);
$Result1 = mysql_query($insertSQL, $okay) or die(mysql_error());

$Url="http://localhost/shm/order_member/auth.php?username=" . $_POST['username']
. "&Auth=" . $_POST['Auth'];

$Body=$_POST['username'] . "你好!<br>"
."歡迎你在*永春學院*註冊<br>"
."若你沒有註冊請忽略這封認證信件<br>"
."<a href=\"" . $Url . "\">"
."點一下這裡認證你的帳號 </a>";

$From= "From: " . "=?UTF-8?B?".base64_encode("永春學院")."?="." <Qoo@hotmail.com> \n\r";
$Type= "Content-Type: text/html; charset=UTF-8\n\r"
."Content-Transfer-Encoding: 8bit\n\r";
$Header=$From.$Type;
$Subject="=?UTF-8?B?".base64_encode("永春學院註冊通知")."?=";

mail($_POST['email'], $Subject, $Body, $Header);

$insertGoTo = "member_center.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>加入會員</title>
<link href="CSS/all.css" rel="stylesheet" type="text/css" />
<link href="CSS/member_new.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryData.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
function CheckFields()
{
// 記住使用者填入的資料
document.cookie = "MY_username=" + document.getElementById("username").value + ";";
document.cookie = "MY_password=" + document.getElementById("password").value + ";";
document.cookie = "MY_name=" + escape(document.getElementById("name").value) + ";";
document.cookie = "MY_year=" + document.getElementById("year").value + ";";
document.cookie = "MY_month=" + document.getElementById("month").value + ";";
document.cookie = "MY_day=" + document.getElementById("day").value + ";";
document.cookie = "MY_email=" + document.getElementById("email").value + ";";
document.cookie = "MY_phone=" + escape(document.getElementById("phone").value) + ";";
document.cookie = "MY_address=" + escape(document.getElementById("address").value) + ";";
document.cookie = "MY_uniform=" + escape(document.getElementById("uniform").value) + ";";
document.cookie = "MY_unititle=" + escape(document.getElementById("unititle").value) + ";";

var sex = "男";
if (document.member_new_form.sex[1].checked)
sex = "女";
document.cookie = "MY_sex=" + escape(sex) + ";";

// 檢查『帳號』欄位
var fieldvalue = document.getElementById("username").value;
if (fieldvalue == "")
{
alert("『帳號』欄位不可以是空白!");
document.getElementById("username").focus();
return false;
}
else if (fieldvalue.length < 3 || fieldvalue.length > 10)
{
alert("『帳號』欄位的長度必須是6~12個字元!");
document.getElementById("username").focus();
return false;
}
else if (fieldvalue.search(/[\u4E00-\u9FA5]/g) != -1)
{
alert("『帳號』欄位不可以是中文!");
document.getElementById("username").focus();
return false;
}

// 檢查『密碼』欄位
fieldvalue = document.getElementById("password").value;
if (fieldvalue == "")
{
alert("『密碼』欄位不可以是空白!");
document.getElementById("password").focus();
return false;
}
else if (fieldvalue.length < 6 || fieldvalue.length > 12)
{
alert("『密碼』欄位的長度必須是6~12個字元!");
document.getElementById("password").focus();
return false;
}
else if (fieldvalue.search(/[\W]/g) != -1)
{
alert("『密碼』欄位必須是英文字母與數字!");
document.getElementById("password").focus();
return false;
}

// 檢查『姓名』欄位
fieldvalue = document.getElementById("name").value;
if (fieldvalue == "")
{
alert("『姓名』欄位不可以是空白!");
document.getElementById("name").focus();
return false;
}

// 檢查『電子信箱』欄位
fieldvalue = document.getElementById("email").value;
if (fieldvalue == "")
{
alert("『電子信箱』欄位不可以是空白!");
document.getElementById("email").focus();
return false;
}
else if (fieldvalue.search(/^\w+((\.\w+)|(-\w+))*@\w+((\.|-)\w+)*\.\w+$/) == -1)
{
alert("『電子信箱』欄位的格式不正確!");
document.getElementById("email").focus();
return false;
}

// 檢查『年』欄位
fieldvalue = document.getElementById("year").value;
if (fieldvalue == "")
{
alert("『年』欄位不可以是空白!");
document.getElementById("year").focus();
return false;
}
else if (fieldvalue.search(/[\D]/g) != -1)
{
alert("『年』欄位必須是數字!");
document.getElementById("year").focus();
return false;
}
else if (fieldvalue < 1900 || fieldvalue > 2010)
{
alert("『年』欄位的值必須在 1900 ~ 2010 之間!");
document.getElementById("year").focus();
return false;
}

// 檢查『連絡電話』欄位
fieldvalue = document.getElementById("phone").value;
if (fieldvalue == "")
{
alert("『連絡電話』欄位不可以是空白!");
document.getElementById("phone").focus();
return false;
}

// 檢查『收件地址』欄位
fieldvalue = document.getElementById("address").value;
if (fieldvalue == "")
{
alert("『收件地址』欄位不可以是空白!");
document.getElementById("address").focus();
return false;
}

// 設定 birthday 欄位的值
document.getElementById("birthday").value = document.getElementById("year").value + "-" +
document.getElementById("month").value + "-" + document.getElementById("day").value;

// 檢查帳號是否已經存在?
checkUsernameExist(document.getElementById("username").value);

return true;
}

function myCallBack(req)
{
var count = req.xhRequest.responseText;

if (count > 0)
{
alert(req.userData.username + "\r\n此帳號已被他人使用, 請您重新輸入");
// 不要插入新的會員記錄
document.getElementById("MM_insert").value = "";
}
}

function checkUsernameExist(username)
{
var objUserData = new Object;
objUserData.username = username;

var req = Spry.Utils.loadURL("GET","member_new_check.php?username="+username, false, myCallBack, {userData: objUserData});
}
//-->
</script>
<script type="text/javascript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<body>
<table class="all_style1">
<tr>
<td colspan="2" align="left" valign="top" class="all_style2">
<?php require_once('top.php'); ?>
</td>
</tr>
<tr>
<td align="left" valign="top" class="all_style3">
<?php require_once('left.php'); ?>
</td>
<td align="left" valign="top" class="all_style4">
<table class="all_style1">
<tr>
<td align="left" valign="top" class="all_style2">
<form action="<?php echo $editFormAction; ?>" id="member_new_form" name="member_new_form"
method="POST" onkeydown="if (event.keyCode==13) return false;">
<table align="center" class="member_new_style1">
<tr>
<td align="center" valign="middle"
class="member_new_style2">
<span class="member_new_style3">
加入會員
</span>
</td>
</tr>
<tr>
<td align="left" valign="top" class="member_new_style4">
<table class="member_new_style5">
<tr>
<td colspan="2" align="left" valign="top"
class="member_new_style6">
<strong>
注意事項
</strong>
<ol>
<li>
為方便您購物時能確實收到商品,請務必正確填寫以
下資料。(*欄位為必填)
<br />
</li>
<li>
我們會將認證信函寄到您的電子信
</li>
</ol>
<hr class="member_new_style10" />
</td>
</tr>
<tr>
<td align="center" valign="middle" class="member_new_style7">
<span class="member_new_style11">
帳  號
</span>
</td>
<td class="member_new_style4">
<input name="username" type="text" id="username" size="20" maxlength="10"
value="<?php echo $_COOKIE['MY_username']; ?>" />
*(3~10個字元,請勿使用中文)
</td>
</tr>
<tr>
<td align="center" valign="middle" class="member_new_style7">
<span class="member_new_style11">
密  碼
</span>
</td>
<td class="member_new_style4">
<input name="password" type="password" id="password" size="22" maxlength="12"
value="<?php echo $_COOKIE['MY_password']; ?>" />
*(6~12個字元,請勿使用中文)
</td>
</tr>
<tr>
<td align="center" valign="middle"
class="member_new_style7">
<span class="member_new_style11">
姓  名
</span>
</td>
<td class="member_new_style4">
<input name="name" type="text" id="name" size="20" maxlength="40"
value="<?php echo uniDecode($_COOKIE['MY_name']); ?>" />

</td>
</tr>
<tr>
<td align="center" valign="middle"
class="member_new_style7">
<span class="member_new_style11">
性  別
</span>
</td>
<td class="member_new_style4">
<input name="sex" type="radio" value="男"
<?php
if (!empty($_COOKIE['MY_sex']))
{
if (uniDecode($_COOKIE['MY_sex']) == "男")
{
echo "checked=\"checked\"";
}
}
else
{
echo "checked=\"checked\"";
}
?> />
&nbsp;男&nbsp;
<input name="sex" type="radio" value="女"
<?php
if (!empty($_COOKIE['MY_sex']))
{
if (uniDecode($_COOKIE['MY_sex']) == "女")
{
echo "checked=\"checked\"";
}
}
?> />
&nbsp;女&nbsp;
</td>
</tr>
<tr>
<td align="center" valign="middle"
class="member_new_style7">
<span class="member_new_style11">
電子信箱
</span>
</td>
<td class="member_new_style4">
<input name="email" type="text" id="email" size="40" maxlength="40"
value="<?php echo $_COOKIE['MY_email']; ?>" />

</td>
</tr>
<tr>
<td align="center" valign="middle"
class="member_new_style7">
<span class="member_new_style11">
出生日期
</span>
</td>
<td class="member_new_style4">
<input name="year" type="text" id="year" size="6" maxlength="4"
value="<?php echo $_COOKIE['MY_year']; ?>" />
&nbsp;年&nbsp;
<select name="month" id="month">
<?php
for ($i = 1; $i <= 12; $i++)
{
?>
<option value="<?php echo $i ?>"
<?php
if (!empty($_COOKIE['MY_month']))
{
if ($i == $_COOKIE['MY_month'])
{
echo "selected=\"selected\"";
}
}
?>>
&nbsp;&nbsp;<?php echo $i ?>&nbsp;
</option>
<?php
}
?>
</select>
&nbsp;月&nbsp;&nbsp;
<select name="day" id="day">
<?php
for ($i = 1; $i <= 31; $i++)
{
?>
<option value="<?php echo $i ?>"
<?php
if (!empty($_COOKIE['MY_day']))
{
if ($i == $_COOKIE['MY_day'])
{
echo "selected=\"selected\"";
}
}
?>>
&nbsp;&nbsp;<?php echo $i ?>&nbsp;&nbsp;
</option>
<?php
}
?>
</select>
&nbsp;日&nbsp;&nbsp;(請填入西元年, 例如 2009)*
</td>
</tr>
<tr>
<td align="center" valign="middle"
class="member_new_style7">
<span class="member_new_style11">
連絡電話
</span>
</td>
<td class="member_new_style4">
<input name="phone" type="text" id="phone" size="20" maxlength="15"
value="<?php echo uniDecode($_COOKIE['MY_phone']); ?>" />

</td>
</tr>
<tr>
<td align="center" valign="middle"
class="member_new_style7">
<span class="member_new_style11">
收件地址
</span>
</td>
<td class="member_new_style4">
<input name="address" type="text" id="address" size="60" maxlength="120"
value="<?php echo uniDecode($_COOKIE['MY_address']); ?>" />

</td>
</tr>
<tr>
<td align="center" valign="middle"
class="member_new_style7">
<span class="member_new_style11">
統一編號
</span>
</td>
<td class="member_new_style4">
<input name="uniform" type="text" id="uniform" size="20" maxlength="20"
value="<?php echo uniDecode($_COOKIE['MY_uniform']); ?>" />
</td>
</tr>
<tr>
<td align="center" valign="middle"
class="member_new_style7">
<span class="member_new_style11">
發票抬頭
</span>
</td>
<td class="member_new_style4">
<input name="unititle" type="text" id="unititle" size="40" maxlength="40"
value="<?php echo uniDecode($_COOKIE['MY_unititle']); ?>" />
</td>
</tr>
<tr>
<td colspan="2" align="center" class="member_new_style9">
<hr class="member_new_style10" />
<input name="Auth" type="hidden" id="Auth" value="<?php echo $authcode=substr((uniqid(rand())), 0, 10); ?>" />
<input name="member_new_submit" type="submit" id="member_new_submit"
value="確定送出" onclick="return CheckFields();" />
&nbsp;&nbsp;&nbsp;&nbsp;
<input name="member_new_cancel" type="button" id="member_new_cancel"
onclick="MM_goToURL('parent','member_center.php');return document.MM_returnValue" value="取消" />
<hr class="member_new_style10" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<input name="userlevel" type="hidden" value="0" />
<input name="birthday" type="hidden" />
<input type="hidden" name="MM_insert" value="member_new_form" />
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

搜尋相關Tags的文章: [ 會員 ] , [ 認證註冊 ] , [ 認證連結 ] , [ ] ,
本篇文章發表於2011-05-13 12:46
1樓
回應

浩瀚星空
捐贈 VP 給 浩瀚星空 檢舉此回應
請先詳看
http://www.blueshop.com.tw/board/FUM20041006152627A9N/BRD20090907182243QWG.html
後再來重新發問好嗎??

看樣子又是一個DW的套用者發生問題不明白。
整理一下你的主要問題。了解一下那些套用的東西是幹什麼。
程式帶一下代碼並做縮排處理吧。

不要想要人幫忙卻照成要幫忙你的人麻煩。
本篇文章回覆於2011-05-13 14:21
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
2樓
不錯的參考

那顆爛蔥
捐贈 VP 給 那顆爛蔥 檢舉此回應
1.COOKIE別亂用
2.登入部份似乎沒列,天曉得你怎麼處理登入的驗證?
3.哪段是哪個程式?這樣列出來,沒幾隻貓會想看你的程式
本篇文章回覆於2011-05-14 05:22
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
3樓
不錯的參考

得意
捐贈 VP 給 得意 檢舉此回應
2F 2
說的是正確的
你的程式根本不是登入畫面

給你一個流程概念

你在登入頁面中要有AUTH欄位是否是已經認證的判斷
如果還未認證的話
認證使用者ID的session 是不可以給他值(你應該是給他值了)
然後導到認證畫面去
請他手動認證
如認證成功
再到登入畫面
這是大致的流程

寫程式
流程是很重要的
練拳不練功 到頭一場空
加油吧!
本篇文章回覆於2011-05-16 12:40
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
4樓
最有價值解答

kg
檢舉此回應
我的作法是在sql增加一個驗證欄位,當user透過email通過驗證時其欄位值為true反之為false...
user login時先去判斷該欄位是否為true?若是表示已通過email驗証並將user ID給cookie or session...
本篇文章回覆於2011-05-20 21:24
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
5樓
回應

yes
檢舉此回應
謝謝大家的回覆~
本篇文章回覆於2011-05-25 17:23
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
   
1

回覆
如要回應,請先登入.