Quote:ไม่ทราบ หน้าล๊อคอิน กับ โค๊ดล๊อคอิน สามารถอยู่หน้าเดียวกานได้รึป่าวครับ
<?php if(!isset($_GET[type]) || $_GET[type]=='login'){?> <form name='login' method='post' action='<? $PHP_SELF?>?type=check'> ..... <form> <?php }else if($_GET[type]== 'check'){ ... ตรวจสอบการ login ถ้าถูกต้อง <meta http-equiv="refresh" content="1;URL=xxx.php"> ถ้าไม่ถูกต้อง <meta http-equiv="refresh" content="1;URL=<?php $PHP_SELF?>?type=login"> <?php }?>
<script> function check(){ .... ขอรวบรัดน่ะ username =document.getElementById('username').value; password =document.getElementById('password').value; if(..readyState ==4 && ....เช็คการติดต่อถูกต้อง){ var resp =xmlHttp.responseText; // ให้ chekclogin.php ส่งค่า echo ว่า login ถูกต้องเปล่า ในที่สมมติง่ายๆ echo 1 หมายถึง login ถูกต้อง echo 0 หมายถึง login ไม่ถูกต้อง if(resp==1){ document.myform.submit(); }else{ ตามสบายเลยจะให้มันโชว์อะไร } } xmlHttp.open("GET","checklogin.php?user="+username+"&pass="+password,true); xmlHttp.send(null); </script> <form name='myform' ......> ... <a href="javascript:check()"/>blah blah </form>
<?php if(!isset($_GET[type]) || $_GET[type]=='login'){?> // ถ้ายังไม่มีการ login หรือ type=login ก็ให้ทำตรงนี้ <form name='login' method='post' action='<? $PHP_SELF?>?type=check'> <input type="text" name='username' value='username'/><br/> <input type="password" name='password' value="password" /> <input type="submit" value="submit"/> เมื่อกด submit จะโหลดหน้านี้และส่งค่า GET type=check ไป <form> <?php }else if($_GET[type]== 'check'){ // หลังจากกด submit ค่า GET type== check จริงก็ทำตรงนี้ต่อ ... ตรวจสอบการ login // เป็นโค้ดที่จะเช็ค .... สมมติ $rs=mysql_fetch_array($mysql); if($_POST['username']==$rs[username] && $_POST['password'] ==$rs[password] ){ user และพาสถูกต้อง echo '<meta http-equiv="refresh" content="1;URL=xxx.php">'; ให้ไปหน้าต่อไป ถ้าไม่ถูกต้อง }else{ ถ้าไม่ถูกต้อง echo '<script> alert("username หรือ password ไม่ถูกต้อง") </script>'; ให้เตื่อนด้วย alert echo '<meta http-equiv="refresh" content="1;URL=<?php $PHP_SELF?>?type=login">'; จากนั้นก็ refresh หน้าเดิมแล้วส่ง GET type=login มันก็จะกลับไปสร้าง tag form login ให้ใหม่ครับ <?php }?>
<? session_start(); include "connect.php"; if ($submit=!""){ $sql="select * from customer where CustLogin ='".trim($username)."' and CustPwd ='".trim($password)."' "; $re=mysql_query($sql) or die(error()); if(mysql_num_rows($re)) { // login done }else{ // user cannot be found } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> artdrinker </TITLE> </HEAD> <BODY> <form action="login.php" method="post"> <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#99CCFF"> <tr bgcolor="#99CCFF"> <td width="27%" align="center"> </td> <td width="73%"></td> </tr> <tr bgcolor="#99CCFF"> <td width="27%" align="center">ÃËÑʼÙéãªé</td> <td width="73%"><input name="user" type="text" id="user" size="30"></td> </tr> <tr bgcolor="#99CCFF"> <td align="center">ÃËÑʼèÒ¹</td> <td><input name="password" type="password" id="password" size="30"></td> </tr> <tr bgcolor="#99CCFF"> <td height="42" colspan="2"><div align="center"> <input type="submit" name="submit" value=" à¢éÒÃкº "> <input type="reset" name="Submit2" value=" ¡àÅÔ¡ "> </div></td> </tr> </table> </form> </BODY> </HTML>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง