|
 |
|
ถ้าเจอข้อมูลในฐานข้อมูล แล้วข้อความใน textbox หายหมดเลยค่ะ แก้ไงดีอ่ะค่ะ รบกวนด้วยนะค่ะ |
|
 |
|
|
 |
 |
|
ถ้าเจอข้อมูลในฐานข้อมูล แล้วข้อความใน textbox หายหมดเลยค่ะ แก้ไงดีอ่ะค่ะ รบกวนด้วยนะค่ะ
Code (PHP)
include("connect.inc.php");
$rs = "SELECT * FROM member where Username='$Username'";
$rs=mysql_query("select * from member where Username='$Username'",$conn);
$num = mysql_num_rows($rs);
if($num > 0){
echo "<script language='JavaScript'>alert('Username นี้ถูกใช้แล้ว');</script>";
}
else{
$sql = "insert into member(Name,Surname,Id_Card,E_Mail,Username,Password) values('$Name','$Surname','$Idinify_Card','$E_mail','$Username','$Password')";
mysql_query($sql,$conn) or die("คำสั่งผิดพลาด".mysql_error());
mysql_close($conn);
echo "<script language='JavaScript'>alert('บันทึกข้อมูลสำเร็จ');</script>";
echo "<meta http-equiv='refresh' content='0; URL = main.php' />";
}
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-10-11 18:38:42 |
By :
conanco |
View :
913 |
Reply :
7 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
งง หายยังไง

|
 |
 |
 |
 |
Date :
2009-10-11 20:11:14 |
By :
petro152 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หายจ้อย คนถามนะ ไม่ใช่ text box
|
 |
 |
 |
 |
Date :
2009-10-12 09:54:06 |
By :
Sek-Artdrinker |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
  ไม่หายได้ไงละครับ ไม่เห็นมีแท็กบ็อกซักกะอัน
|
 |
 |
 |
 |
Date :
2009-10-12 10:00:51 |
By :
NanoThoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โทษทีค่า
Code (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>สมัครสมาชิก</title>
<style type="text/css">
<!--
body {
background-color: #FFFF66;
}
.style3 {font-size: 18; }
.style4 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style></head>
<body >
<div align="center">
<form name="form1" method="post" action="apply.php" >
<table width="501" border="1">
<tr>
<td colspan="2" bgcolor="#663300"><div align="center" class="style4">
<div align="center">สมัครสมาชิกใหม่</div>
</div></td>
</tr>
<tr>
<td width="130" bgcolor="#CCCC66"><div align="right"><font color="#330066">ชื่อ </font>:</div></td>
<td width="355" bgcolor="#CCCC66"><div align="left">
<input name="Name" type="text" size="48" maxlength="30" />
** </div></td>
</tr>
<tr>
<td bgcolor="#CCCC66"><div align="right"><font color="#330066">นามสกุล </font>:</div></td>
<td bgcolor="#CCCC66"><div align="left">
<input name="Surname" type="text" size="48" maxlength="30" />
** </div></td>
</tr>
<tr>
<td bgcolor="#CCCC66"><div align="right"><font color="#330066">รหัสบัตรประชาชน </font>:</div></td>
<td bgcolor="#CCCC66"><div align="left">
<input name="Idinify_Card" type="text" size="30" maxlength="13" />
** </div></td>
</tr>
<tr>
<td bgcolor="#CCCC66"><div align="right"><font color="#330066">E_mail </font>:</div></td>
<td bgcolor="#CCCC66"><div align="left">
<input name="E_mail" type="text" size="48" maxlength="50" />
** </div></td>
</tr>
<tr>
<td bgcolor="#CCCC66"><div align="right"><span class="style3"><font color="#330066">Username </font>:</span></div></td>
<td bgcolor="#CCCC66"><p align="left" class="style3">
<input name="Username" type="text" size="20" maxlength="8" />
**
( ไม่เกิน 8 ตัวอักษร)</p> </td>
</tr>
<tr>
<td bgcolor="#CCCC66"><div align="right"><span class="style3"><font color="#330066">Password</font> : </span></div></td>
<td bgcolor="#CCCC66"><div align="left"><span class="style3">
<input name="Password" type="password" id="pass" size="20" maxlength="8" />
** ( ไม่เกิน 8 ตัวอักษร)</span></div></td>
</tr>
<tr>
<td bgcolor="#CCCC66"><div align="right"><font color="#330066">Re-Password </font>: </div></td>
<td bgcolor="#CCCC66"><div align="left">
<input name="repass" type="password" id="repass" size="20" maxlength="8" />
** </div></td>
</tr>
<tr>
<td colspan="2" bgcolor="#CCCC66">
<div align="center">
<input type="submit" name="Submit" value="สมัคร" onclick="return Check();" />
<input type="reset" name="Reset" value="เคลียร์" />
<input type="button" name="Cancel" value="ยกเลิก" onclick="main.php"/>
</div></td>
</tr>
</table>
<p>
<script language="javascript">
function Check(){
if(document.getElementById("Name").value!="" && document.getElementById("Surname").value!="" && document.getElementById("Username").value!="" && document.getElementById("Password").value!="" && document.getElementById("repass").value!="" && document.getElementById("Idinify_Card").value!="" && document.getElementById("E_mail").value!=""){
if(checkID(document.form1.Idinify_Card.value)){
if(document.getElementById("Password").value == document.getElementById("repass").value){
return true;
}
else{
alert('คุณยืนยันข้อมูลไม่ถูกต้องคะ');
return false;
}
}
else{
alert('รหัสบัตรประชาชนไม่ถูกต้อง กรุณารหัสบัตรประชาชนให้ถูกต้องด้วยคะ');
return false;
}
}
else {
alert('กรุณาใส่ให้ครบทุกช่องด้วยคะ');
return false;
}
}
function checkID(Idinify_Card) {
if(Idinify_Card.length != 13){
return false;
}
for(i=0, sum=0; i < 12; i++){
sum += parseFloat(Idinify_Card.charAt(i))*(13-i);
}
if((11-sum%11)%10!=parseFloat(Idinify_Card.charAt(12))){
return false;
}
return true;
}
</script>
<?
if(isset($Name)){
if($Username != "" && $Idinify_Card != ""){
include("connect.inc.php");
$rs = "SELECT * FROM member where Username='$Username'";
$rs=mysql_query("select * from member where Username='$Username'",$conn);
$rs1=mysql_query("select * from member where Id_Card='$Idinify_Card'",$conn);
$num = mysql_num_rows($rs);
$num1 = mysql_num_rows($rs1);
if($num > 0){
echo "<script language='JavaScript'>alert('Username นี้ถูกใช้แล้ว');</script>";
}
if($num1 > 0){
echo "<script language='JavaScript'>alert('รหัสประชาชนนี้ถูกใช้แล้ว');</script>";
}
else{
$sql = "insert into member(Name,Surname,Id_Card,E_Mail,Username,Password) values('$Name','$Surname','$Idinify_Card','$E_mail','$Username','$Password')";
mysql_query($sql,$conn) or die("คำสั่งผิดพลาด".mysql_error());
mysql_close($conn);
echo "<script language='JavaScript'>alert('บันทึกข้อมูลสำเร็จ');</script>";
echo "<meta http-equiv='refresh' content='0; URL = main.php' />";
}
}
else{
echo "<script language='JavaScript'>alert('กรุณากรอกข้อมูลให้ครบ');</script>";
}
}
?>
</p>
</form>
</div>
</body>
</html>
|
 |
 |
 |
 |
Date :
2009-10-12 11:56:48 |
By :
conanco |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือ เวลากด Submit แล้วตรวจสอบว่า username มีคนใช้แล้วจะขึ้นข้อความเตือนแล้วข้อความใน textbox หายไปอ่ะค่ะ
|
 |
 |
 |
 |
Date :
2009-10-12 17:16:01 |
By :
conanco |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|