|
|
|
รบกวนดูหน้าฟอร์มให้ทีคับ ไม่รู้ว่าจะเขียนโค้ดแทรกตรงไหน |
|
|
|
|
|
|
|
คือผมอยากทำ ปุ่ม Check User ว่าซ้ำกับที่มีอยู่ในฐานข้อมูลหรือป่าว
แต่ผมสร้างฟอร์มแบบ ใช้ Record set และ Insert Coloumn เข้าไปในฐานข้อมูลคับ
อยากทราบว่าผมจะต้องเขียนโค้ด Check User ยังไง
และ ผมยังอยากทราบอีกว่า ถ้าผมจะเช็ค Retype-Password ว่าตรงกับ Password ที่กรอกตอนแรกหรือป่าว ต้อง
เขียนโค้ดยังไง
Register.php
<?php require_once('Connections/conn_pailyn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO member (idGen, FirstName, LastName, Adress, Username, Password, Email, Mobile, Tel) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Genname'], "text"),
GetSQLValueString($_POST['txtFirstname'], "text"),
GetSQLValueString($_POST['txtLastname'], "text"),
GetSQLValueString($_POST['txtAdress'], "text"),
GetSQLValueString($_POST['txtUser'], "text"),
GetSQLValueString($_POST['txtPass'], "text"),
GetSQLValueString($_POST['txtEmail'], "text"),
GetSQLValueString($_POST['txtTel'], "text"),
GetSQLValueString($_POST['txtTelin'], "text"));
mysql_select_db($database_conn_pailyn, $conn_pailyn);
$Result1 = mysql_query($insertSQL, $conn_pailyn) or die(mysql_error());
$insertGoTo = "Index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_conn_pailyn, $conn_pailyn);
$query_rsMember = "SELECT * FROM member";
$rsMember = mysql_query($query_rsMember, $conn_pailyn) or die(mysql_error());
$row_rsMember = mysql_fetch_assoc($rsMember);
$totalRows_rsMember = mysql_num_rows($rsMember);
mysql_select_db($database_conn_pailyn, $conn_pailyn);
$query_rsGender = "SELECT * FROM gender";
$rsGender = mysql_query($query_rsGender, $conn_pailyn) or die(mysql_error());
$row_rsGender = mysql_fetch_assoc($rsGender);
$totalRows_rsGender = mysql_num_rows($rsGender);
?>
<!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=windows-874" />
<title>Register</title>
<SCRIPT language=JavaScript>
function check_number() {
e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
if (e_k != 13 && (e_k < 48) || (e_k > 57)) {
event.returnValue = false;
alert("กรุณาใส่ตัวเลขค่ะ");
}
}
</script>
<style type="text/css">
<!--
.style26 {font-family: Tahoma}
.style44 {font-family: Tahoma; font-size: 14px; color: #000000; }
.style47 {font-family: Tahoma; color: #000000; }
.style49 {color: #C41130}
.style60 {
font-family: "KT Wonderfool";
font-size: 26px;
}
.style74 {color: #C41130; font-family: Tahoma; }
.style75 {
font-size: 14px;
font-weight: bold;
}
-->
</style>
</head>
<body>
<table width="955" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th height="250" colspan="2" align="left" valign="top" bordercolor="#E7EAEE" background="Images/bg[1].jpg" scope="col"><p> </p> </th>
</tr>
<tr>
<th width="470" height="68" align="left" valign="top" scope="row"><img src="Images/step1_th[4].png" width="470" height="68" /></th>
<th width="485" align="left" valign="top" background="Drag to a file to choose it." scope="row"><a href="Index.php"><img src="Images/step1_th[5].png" width="485" height="68" border="0" /></a></th>
</tr>
<tr>
<th height="30" colspan="2" align="left" scope="row"><form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="955" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td height="40" class="style60"> </td>
<td height="40"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40" class="style60">ข้อมูลการลงทะเบียน</td>
<td width="422" height="40"> </td>
<td width="167"> </td>
</tr>
<tr>
<td width="163"> </td>
<td width="203" height="40" class="style44">Username : </td>
<td height="40"><span class="style47">
<input name="txtUser" type="text" id="txtUser" maxlength="25" style="width:250px"/>
<span class="style49">*
<input type="submit" name="btnCheck" id="btnCheck" value="Check User" />
</span></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40"><span class="style44">Password :</span></td>
<td height="40"><span class="style47">
<input name="txtPass" type="password" id="txtPass" maxlength="25" style="width:250px"/>
<span class="style49">*</span></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40"><span class="style44">Re-type Password :</span></td>
<td height="40"><span class="style47">
<input name="txtRepass" type="password" id="txtRepass" maxlength="25" style="width:250px"/>
<span class="style49">*</span></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40"><span class="style44">Email :</span></td>
<td height="40"><span class="style47">
<input name="txtEmail" type="text" id="txtEmail" maxlength="50" style="width:250px"/>
<span class="style49">*</span></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40"> </td>
<td height="40"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40" class="style60">ข้อมูลส่วนตัว</td>
<td height="40"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40"><span class="style44">ชื่อ :</span></td>
<td height="40"><span class="style47">
<input name="txtFirstname" type="text" id="txtFirstname" maxlength="50" style="width:250px"/>
<span class="style49">*</span></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40"><span class="style44">นามสกุล :</span></td>
<td height="40"><span class="style47">
<input name="txtLastname" type="text" id="txtLastname" maxlength="50" style="width:250px"/>
<span class="style49">*</span></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40"><span class="style44">เพศ :</span></td>
<td height="40"><span class="style74">
<select name="Genname" id="Genname">
<?php
do {
?>
<option value="<?php echo $row_rsGender['idGen']?>"<?php if (!(strcmp($row_rsGender['idGen'], $row_rsMember['idGen']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsGender['GenName']?></option>
<?php
} while ($row_rsGender = mysql_fetch_assoc($rsGender));
$rows = mysql_num_rows($rsGender);
if($rows > 0) {
mysql_data_seek($rsGender, 0);
$row_rsGender = mysql_fetch_assoc($rsGender);
}
?>
</select>
*</span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40"><span class="style44">ที่อยู่ :</span></td>
<td height="40"><span class="style47">
<input name="txtAdress" type="text" id="txtAdress" maxlength="70" style="width:250px"/>
<span class="style49">*</span></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40"><span class="style44">เบอร์โทรศัพท์ :</span></td>
<td height="40"><span class="style47">
<input name="txtTel" type="text" id="txtTel" maxlength="10" onkeypress=check_number() style="width:250px" />
<span class="style49">*</span></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40"><span class="style44">เบอร์โทรภายใน : </span></td>
<td height="40"><input name="txtTelin" type="text" id="txtTelin" maxlength="4" onkeypress=check_number() style="width:250px" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td height="40"> </td>
<td height="40"><span class="style26">
<label>
<input type="submit" name="btnOk" id="btnOk" value=" ตกลง " />
<input type="reset" name="btnReset" id="btnReset" value="ล้างฟอร์ม" />
</label>
</span></td>
<td> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form> </th>
</tr>
<tr>
<th height="45" colspan="2" align="left" background="Images/bg-footer[2].png" scope="row">
<MARQUEE onmouseover=stop(); onmouseout=start();>
<img src="Images/Footer(runner).png" width="350" height="24" />
</MARQUEE>
</th>
</th>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($rsMember);
mysql_free_result($rsGender);
?>
Tag : - - - -
|
|
|
|
|
|
Date :
2009-09-29 17:37:06 |
By :
gungrave |
View :
900 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยาวไปเปล่าเนี้ยะ ไม่รู้จะบอกยังไงเลย
|
|
|
|
|
Date :
2009-09-29 18:55:24 |
By :
onizike |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากคับ
|
|
|
|
|
Date :
2009-09-29 22:18:03 |
By :
gungrave |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|