<?php // signup.php include_once 'show_menu.php'; ?> <!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>Untitled Document</title> <style type="text/css"> body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } </style> </head> <body> <table width="980" border="0" align="center" cellspacing="0"> <tr> <td height="40"> <script> function checkUser(user) { if (user.value == "") { document.getElementById("info").innerHTML = "" return } params = "user=" + user.value request = new ajaxRequest() request.open("POST", "checkuser.php", true) request.setRequestHeader("Content-type", "application/x-www-form-urlencoded") request.setRequestHeader("Content-length", params.length) request.setRequestHeader("Connection", "close") request.onreadystatechange = function() { if (this.readyState == 4) { if (this.status == 200) { if (this.responseText != null) { document.getElementById("info").innerHTML = this.responseText } else alert("AJAX ทำงานผิดพลาด: ไม่ได้รับข้อมูล") } else alert( "AJAX ทำงานผิดพลาด: " + this.statusText) } } request.send(params) } function ajaxRequest() { var request = new XMLHttpRequest() if(window.ActiveXObject) { request = new ActiveXObject("Microsoft.XMLHTTP"); return request }else if(window.XMLHttpRequest) { request = new XMLHttpRequest() return request } return false } </script> <h3>ลงทะเบียน</h3><? $error = $user = $pass = ""; if (isset($_SESSION['user'])) destroySession(); if (isset($_POST['user'])) { $user = filterString($_POST['user']); $pass = filterString($_POST['pass']); if ($user == "" || $pass == "") { $error = "กรุณากำหนด Username และ Password ที่ต้องการ<br /><br />"; } else { $query = "SELECT * FROM usersdetail WHERE user='$user'"; if (mysql_num_rows(queryMysql($query))) { $error = "มีผู้ใช้ Username นี้แล้ว<br /><br />"; } else { $query = "INSERT INTO usersdetail VALUES('$user', '$pass')"; queryMysql($query); } die("<h4>สร้างบัญชีผู้ใช้แล้ว</h4>กรุณา Login เข้าระบบ"); } } echo <<<_END <form method='post' action='signup.php'>$error Username <input type='text' maxlength='16' name='user' value='$user' onBlur='checkUser(this)'/><span id='info'></span><br /> Password <input type='text' maxlength='16' name='pass' value='$pass' /><br /> <input type='submit' value='ลงทะเบียน' /> </form> _END; ?></td> </tr> </table> </body> </html>
<!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>Untitled Document</title> </head> <body> <form name="form1" method="post" action="save_register.php"> Register Form <br> <table width="400" border="1" style="width: 400px"> <tbody> <tr> <td width="125"> Username</td> <td width="180"> <input name="user" type="text" id="user" size="20"> </td> </tr> <tr> <td> Password</td> <td><input name="pass" type="password" id="pass"> </td> </tr> </tbody> </table> <br> <input type="submit" name="Submit" value="Save"> </form> </body> </html>
<!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>Untitled Document</title> </head> <body> <? mysql_connect("localhost","root","1234"); mysql_select_db("social network"); if(trim($_POST["user"]) == "") { echo "Please input Username!"; exit(); } if(trim($_POST["pass"]) == "") { echo "Please input Password!"; exit(); } $strSQL = "SELECT * FROM usersdetail WHERE user = '".trim($_POST['user'])."' "; $objQuery = mysql_query($strSQL); $objResult = mysql_fetch_array($objQuery); if($objResult) { echo "Username already exists!"; } else { $strSQL = "INSERT INTO usersdetail (user,pass) VALUES ('".$_POST["user"]."', '".$_POST["pass"]."')"; $objQuery = mysql_query($strSQL); echo "Register Completed!<br>"; echo "<br> Go to <a href='login.php'>Login page</a>"; } mysql_close(); ?> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง