|
|
|
Activation ยืนยันการสมัครสมาชิกทางอีเมล์ มีปัญหาครับ |
|
|
|
|
|
|
|
จากบนความนี้
https://www.thaicreate.com/community/php-member-register-email-activation.html
ผมมีปัญหา ตรงที่ ว่า SID ใน Database มันไม่ แสดง ใน ช่อง SID นะครับ รบกวน หน่อยนะครับ
register
<html>
<head>
<title>ThaiCreate.Com Ajax Tutorial</title>
</head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript">
var HttPRequest = false;
function check() {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'checkregister.php';
var pmeters = "tUsername=" + encodeURI( document.getElementById("txtUsername").value) +
"&tPassword=" + encodeURI( document.getElementById("txtPassword").value ) +
"&tPassword_cf=" + encodeURI( document.getElementById("txtPassword_cf").value ) +
"&tEmail=" + encodeURI( document.getElementById("txtEmail").value );
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
if(HttPRequest.responseText == 'Y')
{
window.location = 'registerfinish.php';
}
else
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
}
</script>
<body>
<h1>Register Form</h1>
<form name="frmMain" method="post" >
<span id="mySpan"></span>
<table width="274" border="1">
<tr>
<th width="117">
<div align="left">Diary</div></th>
<th><input type="text" name="txtUsername" id="txtUsername" size="20"></th>
</tr>
<tr>
<th width="117">
<div align="left">Password</div></th>
<th><input type="password" name="txtPassword" id="txtPassword" size="20"></th>
</tr>
<tr>
<th width="117">
<div align="left">Password_cf</div></th>
<th><input type="Password" name="txtPassword_cf" id="txtPassword_cf" size="20"></th>
</tr>
<tr>
<th width="117">
<div align="left">E-mail</div></th>
<th width="236"><input type="text" name="txtEmail" id="txtEmail" size="20"></th>
</tr>
</table>
<br>
<input name="btnRegister" type="button" id="btnRegister" OnClick="JavaScript:check();" value="Register">
</form>
</body>
</html>
checkregister
<?php
$strUsername = trim($_POST["tUsername"]);
$strPassword = trim($_POST["tPassword"]);
$strPassword_cf = trim($_POST["tPassword_cf"]);
$strEmail = trim($_POST["tEmail"]);
if(trim($strUsername) == "")
{
echo "<font color=red>**</font> Plase input [Username]";
exit();
}
if(trim($strPassword) == "")
{
echo "<font color=red>**</font> Plase input [Password]";
exit();
}
if(trim($strPassword_cf) == "")
{
echo "<font color=red>**</font> Plase input [strPassword_cf]";
exit();
}
if(trim($strEmail) == "")
{
echo "<font color=red>**</font> Plase input [Email]";
exit();
}
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("my");
$strSQL = "SELECT * FROM account WHERE Username = '".$strUsername."' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "<font color=red>**</font> Username [$strUsername] already exists";
}
else
{
$strSQL = "INSERT INTO account (Username,Password_cf,Email,SID,Active) VALUES ('".$strUsername."',
'".$strPassword_cf."','".$strEmail."','".session_id()."','No')";
$objQuery = mysql_query($strSQL);
}
mysql_close($objConnect);
?>
ส่วนอันนี้เป็น รูป ดาด้า ที่ ไม่แสดง นะครับบ
Tag : PHP, MySQL, HTML/CSS, Ajax, CakePHP
|
ประวัติการแก้ไข 2013-11-06 22:09:24
|
|
|
|
|
Date :
2013-11-06 22:08:33 |
By :
thegooddog |
View :
702 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังไม่ได้เปิดใช้งาน Session เลยนิครับ XD แล้วจะเรียกค่า session_id() ได้อย่างไร?
|
|
|
|
|
Date :
2013-11-06 22:24:15 |
By :
ALTELMA |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|