รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ
Moderators: mindphp, ผู้ดูแลกระดาน
-
- PHP Jr. Member
- Posts: 17
- Joined: 13/08/2012 11:57 pm
รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ
ลองใช้ dreamwawer เช็ค user ซ้ำ ใส่ username เป็น oatgames พอกดซับมิท แล้วขึ้น Unknown column 'Oatgames' in 'where clause' แต่พอใส่ username เป็น user กลับบันทึกได้ แล้วพอลองใส่ username เป็น user อีกครั้ง ก็เช็คซ้ำได้ ตามรูปเลยครับ
ใส่ username เป็น oatgame พอกดซับมิท แล้วขึ้น Unknown column 'Oatgames' in 'where clause' แต่พอใส่ username เป็น user กลับบันทึกได้
ใส่ username เป็น oatgame พอกดซับมิท แล้วขึ้น Unknown column 'Oatgames' in 'where clause' แต่พอใส่ username เป็น user กลับบันทึกได้
-
- PHP Jr. Member
- Posts: 17
- Joined: 13/08/2012 11:57 pm
Re: รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ
อันนี้โค๊ดครับ
Code: Select all
<?php require_once('Connections/Dbconnect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="registererror.php";
$loginUsername = $_POST['user'];
$LoginRS__query = sprintf("SELECT `user` FROM member WHERE `user`=%s", GetSQLValueString($loginUsername, "-1"));
mysql_select_db($database_Dbconnect, $Dbconnect);
$LoginRS=mysql_query($LoginRS__query, $Dbconnect) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
}
}
$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 (`user`, pass, fname, lname, address, tumbon, omper, city, status, age, tel) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['user'], "text"),
GetSQLValueString($_POST['pass'], "text"),
GetSQLValueString($_POST['fname'], "text"),
GetSQLValueString($_POST['lname'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['tumbon'], "text"),
GetSQLValueString($_POST['omper'], "text"),
GetSQLValueString($_POST['city'], "text"),
GetSQLValueString($_POST['status'], "text"),
GetSQLValueString($_POST['age'], "int"),
GetSQLValueString($_POST['tel'], "int"));
mysql_select_db($database_Dbconnect, $Dbconnect);
$Result1 = mysql_query($insertSQL, $Dbconnect) or die(mysql_error());
$insertGoTo = "registerok.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!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>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#apDiv1 {
position: absolute;
left: 54px;
top: 126px;
width: 309px;
height: 400px;
z-index: 1;
font-size: 24;
background-color: #CCCCCC;
}
.front1 {
font-family: "Angsana New";
}
#apDiv2 {
position: absolute;
left: 310px;
top: 14px;
width: 383px;
height: 446px;
z-index: 2;
}
</style>
</head>
<body>
<div id="apDiv1">
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">
<table width="290" height="338" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="106" bgcolor="#CCCCCC">username :</td>
<td width="184" bgcolor="#CCCCCC"><label for="user3"></label>
<input type="text" name="user" id="user3" /></td>
</tr>
<tr>
<td bgcolor="#CCCCCC">password :</td>
<td bgcolor="#CCCCCC"><label for="pass"></label>
<input type="password" name="pass" id="pass" /></td>
</tr>
<tr>
<td height="19" bgcolor="#CCCCCC"> </td>
<td bgcolor="#CCCCCC"> </td>
</tr>
<tr>
<td bgcolor="#CCCCCC">ชื่อ :</td>
<td bgcolor="#CCCCCC"><label for="fname"></label>
<input type="text" name="fname" id="fname" /></td>
</tr>
<tr>
<td bgcolor="#CCCCCC">นามสกุล :</td>
<td bgcolor="#CCCCCC"><label for="lname"></label>
<input type="text" name="lname" id="lname" /></td>
</tr>
<tr>
<td bgcolor="#CCCCCC">อายุ :</td>
<td bgcolor="#CCCCCC"><label for="age"></label>
<input name="age" type="text" id="age" size="3" maxlength="3" /></td>
</tr>
<tr>
<td bgcolor="#CCCCCC">ที่อยู่ :</td>
<td bgcolor="#CCCCCC"><label for="address"></label>
<input name="address" type="text" id="address" size="15" maxlength="15" /></td>
</tr>
<tr>
<td bgcolor="#CCCCCC">ตำบล :</td>
<td bgcolor="#CCCCCC"><label for="tumbon"></label>
<input name="tumbon" type="text" id="tumbon" size="15" maxlength="15" /></td>
</tr>
<tr>
<td bgcolor="#CCCCCC">อำเภอ :</td>
<td bgcolor="#CCCCCC"><label for="omper"></label>
<input name="omper" type="text" id="omper" size="15" maxlength="15" /></td>
</tr>
<tr>
<td bgcolor="#CCCCCC">จังหวัด :</td>
<td bgcolor="#CCCCCC"><label for="city"></label>
<input name="city" type="text" id="city" size="15" maxlength="15" /></td>
</tr>
<tr>
<td height="19" bgcolor="#CCCCCC"> </td>
<td bgcolor="#CCCCCC"> </td>
</tr>
<tr>
<td bgcolor="#CCCCCC">เบอร์โทรติดต่อ :</td>
<td bgcolor="#CCCCCC"><label for="tel"></label>
<input name="tel" type="text" id="tel" size="10" maxlength="10" /></td>
</tr>
<tr>
<td height="19" bgcolor="#CCCCCC">สถานะ</td>
<td bgcolor="#CCCCCC"><label for="label"></label>
<select name="status" id="status">
<option value="สมาชิกโครงการ">สมาชิกโครงการ</option>
<option value="สมาชิกสำรอง">สมาชิกสำรอง</option>
<option value="สมาชิกสวัสดิการ">สมาชิกสวัสดิการ</option>
</select></td>
</tr>
</table>
<p>
<input type="submit" name="button" id="button" value="บันทึก" />
</p>
<input type="hidden" name="MM_insert" value="form1" />
</form></div>
</body>
</html>
- mindphp
- ผู้ดูแลระบบ MindPHP
- Posts: 26644
- Joined: 22/09/2008 6:18 pm
- Contact:
Re: รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ
มันไม่รู้จัก columns Oatgames
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
-
- PHP Jr. Member
- Posts: 17
- Joined: 13/08/2012 11:57 pm
Re: รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ
ยัง งง อยู่ครับ เพราะ oatgames เป็นชื่อที่กรอกในช่อง username ที่ให้ INSERT ลงใน columns user ครับ แต่มันกลับบันทึกลง columns Oatgames ซึ่งไม่มีอยู่นใน mysql อยู่แล้วครับ
พอในช่อง username กรอกเป็น abc มันก็ขึ้น Unknown column 'abc' in 'where clause'
เหมือนกับที่กรอก เป็น oatgames เลยครับ
แต่พอใส่ ในช่อง username กรอกเป็น user กลับสามารถบันทึกลงได้ครับ ใน column ของ user ก็ขึ้นมา 1 แถวตามที่กรอก และสามารถเช็ค ซ้ำได้
เหมือนเดิม พอกรอกชื่ออื่น ไม่ว่าจะเป็นอะไรก็ขึ้นเป็น Unknown column 'ชื่อที่กรอกในช่อง username' in 'where clause'
พอในช่อง username กรอกเป็น abc มันก็ขึ้น Unknown column 'abc' in 'where clause'
เหมือนกับที่กรอก เป็น oatgames เลยครับ
แต่พอใส่ ในช่อง username กรอกเป็น user กลับสามารถบันทึกลงได้ครับ ใน column ของ user ก็ขึ้นมา 1 แถวตามที่กรอก และสามารถเช็ค ซ้ำได้
เหมือนเดิม พอกรอกชื่ออื่น ไม่ว่าจะเป็นอะไรก็ขึ้นเป็น Unknown column 'ชื่อที่กรอกในช่อง username' in 'where clause'
-
- PHP Full Member
- Posts: 33
- Joined: 27/08/2012 1:22 pm
Re: รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ
$insertSQL = sprintf("INSERT INTO member (`user`, pass, fname, lname, address, tumbon, omper, city, status, age, tel) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
ตรง `user` ลองเอา ` ออกดู ถ้ายังไม่ได้ echo $insertSQL ออกมาให้ดูหน่อย ก่อนที่จะสั่ง die;
ตรง `user` ลองเอา ` ออกดู ถ้ายังไม่ได้ echo $insertSQL ออกมาให้ดูหน่อย ก่อนที่จะสั่ง die;
-
- PHP Jr. Member
- Posts: 17
- Joined: 13/08/2012 11:57 pm
Re: รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ
ได้ละครับ เป็นเพราะ `user` จิงๆ พอเอาออกละใส่ได้และครับ ขอบคุณครับ
-
- Similar Topics
- Replies
- Views
- Last post
-
-
รบกวนครับ ต้องการเลือก Radio Button แล้ว Disable ปุ่มอื่น
by demonxiii » 11/07/2011 11:11 am » in JavaScript & Jquery Ajax - 1 Replies
- 5016 Views
-
Last post by touleg
02/08/2011 8:19 pm
-
Who is online
Users browsing this forum: No registered users and 8 guests