<? class signup{ private $username; private $password; private $passmd5; private $email; private $errors; private $token; public function __construct() { $this->errors = array(); $this->username = $this->filter($_POST['ruser']); $this->password = $this->filter($_POST['rpass']); $this->email = $this->filter($_POST['remail']); $this->token = $_POST['token']; $this->passmd5 = md5($this->password); } public function process() { if($this->valid_token() && $this->valid_data()) $this->signup(); return count($this->errors) ? 0 : 1; } public function filter($var) { return preg_replace('/[^a-zA-Z0-5@.]/','',$var); } public function signup() { mysql_connect('localhost', 'root', '1234') or die (mysql_error()); mysql_select_db('social') or die (mysql_error()); mysql_query("INSERT INTO account (username,password) VALUES ('($this->username)','($this->passmd5)')"); if(mysql_affected_rows() < 1) $this->errors[] = 'Could not process Form'; } public function show_errors() { echo "Errors"; foreach($this->errors as $key=>$value) echo $value."<br>"; } public function valid_data() { if(empty($this->username)) $this->errors[] = 'invail username'; if(empty($this->password)) $this->errors[] = 'invail password'; if(empty($this->email) || !ereg('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]\.([a-zA-Z]{2,4})$',$this->email)) $this->errors[] = 'invail email'; return count($this->errors) ? 0 : 1; } public function valid_token() { if(!isset($_SESSION['token']) || $this->token != $_SESSION['token']) $this->errors = 'Incalid subnit'; return count($this->errors) ? 0 : 1; } } ?>
$this->errors = 'Incalid subnit';
$this->errors[] = 'Incalid subnit';
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง