|
 |
|
ขอโทษน่ะครับผมอยากทราบการสมัครสมาชิกครับ ขอโทษน่ะครับผมอยากทราบการสมัครสมาชิกครับ |
|
 |
|
|
 |
 |
|
การสมัครสมาชิกมีไรบ้างคุณลองเอาหน้าแบบฟอร์มของเว็บนี้มาลอกก็ได้ครับเช่น
ชื่อ-นามสกุล เบอร์โทรศัพท์ อีเมล์ ที่อยู่ปัจจุบัน ผู้หญิง-ผู้ชาย ทำเป็น textbox ไว้สำหรับกรอกอ่าครับ ส่วนโค๊ดข้างบนของคุณมันเป็นแค่การคอนเน็คเพื่อเชื่อมต่อกับฐานข้อมูลเท่านั้นครับ หรือว่าผมเข้าใจคุณผิด คุณเอาโค๊ดหน้าฟอร์มมาโพสไว้ที่นี่ครับ แล้วก็ฐานข้อมูลที่คุณสร้างไว้ด้วยครับ
|
 |
 |
 |
 |
Date :
2010-07-01 21:11:39 |
By :
Dragons_first |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<?php
////////////////////////////////////////////
// ตัวอย่าง //
////////////////////////////////////////////
$GLOBLAS['_arr_conn'] = array(
'_host' => 'localhost',
'_user' => 'root',
'_password' => 'root',
'_db' => 'register'
);
define('PREFIX', 'tb_');
///////////////////////////////////////////////////////////////////////////////////////////
if($_POST['_submitted']){
$_user = isset($_POST['_user']) ? htmlspecialchars($_POST['_user']) : ' ';
$_pass = isset($_POST['_password']) ? sha1(htmlspecialchars($_POST['_password'])) : ' ';
$_pass_conf = isset($_POST['_password_conf']) ? sha1(htmlspecialchars($_POST['_password_conf'])) : ' ';
if(strcmp($_pass, $_pass_conf) != 0) die(' กรุณากรอกระหัสผ่านให้เหมือนกัน ');
//check user
$_db = mysql_connect($_arr_conn['_host'],
$_arr_conn['_user'],
$_arr_conn['_pass'],
$_arr_conn['_db']);
mysql_query('SET NAMES utf-8');
$_sql = sprintf(' SELECT COUNT(*) FROM '.PREFIX."register " .
" WHERE %s AND %s ",
mysql_real_escape_string($_user),
mysql_real_escape_string($_pass)
);
$_query = mysql_query($_sql, $_db);
$_num_rows = mysql_num_rows($_query);
if($_num_rows > 0) die(' พบ user นี้ในฐานข้อมูลแล้ว ');
$_sql = sprintf(" INSERT INTO ".PREFIX."register(id, user, password) ".
" VALUES(NULL, %s, %s)",
mysql_real_escape_string($_user),
mysql_real_escape_string($_pass)
);
$_query = mysql_query($_sql, $_db);
if(!$_query) $_result = ' กรอกข้อมูลล้มเหลว ! ! ';
else $_result = ' กรอกข้อมูลเรียบร้อย ! ! ';
mysql_free_result(); mysql_close($_db);
}
// ยกตัวอย่างน่ะครับ ยังใช้งานไม่ได้ ตรวจสอบก่อน
//////////////////////////////////////////////////////////////////////////
?>
<html>
<head>
<title></title>
</head>
<body>
<div id="_result"><?php if($_result !=' ') echo $_result;?></div>
<div id="_contents">
<form action="" method="post">
username : <input type="text" name="_name"> <br>
password : <input type="password" name="_password"><br>
confirm password : <input type="password" name="_password_conf"><br>
<input type="submit" name="submitted" >
</form>
</div>
</body>
</html>
|
 |
 |
 |
 |
Date :
2010-07-01 22:11:14 |
By :
mrjidjad |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|