รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

oatgamess
PHP Jr. Member
PHP Jr. Member
โพสต์: 17
ลงทะเบียนเมื่อ: 13/08/2012 11:57 pm

รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ

โพสต์ที่ยังไม่ได้อ่าน โดย oatgamess »

ลองใช้ dreamwawer เช็ค user ซ้ำ ใส่ username เป็น oatgames พอกดซับมิท แล้วขึ้น Unknown column 'Oatgames' in 'where clause' แต่พอใส่ username เป็น user กลับบันทึกได้ แล้วพอลองใส่ username เป็น user อีกครั้ง ก็เช็คซ้ำได้ ตามรูปเลยครับ

ใส่ username เป็น oatgame
01.jpg
01.jpg (90.52 KiB) Viewed 2830 times
พอกดซับมิท แล้วขึ้น Unknown column 'Oatgames' in 'where clause'
02.jpg
02.jpg (84.6 KiB) Viewed 2830 times
03.jpg
03.jpg (91.59 KiB) Viewed 2830 times
แต่พอใส่ username เป็น user กลับบันทึกได้
04.jpg
04.jpg (180.17 KiB) Viewed 2830 times
oatgamess
PHP Jr. Member
PHP Jr. Member
โพสต์: 17
ลงทะเบียนเมื่อ: 13/08/2012 11:57 pm

Re: รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ

โพสต์ที่ยังไม่ได้อ่าน โดย oatgamess »

อันนี้โค๊ดครับ

โค้ด: เลือกทั้งหมด

<?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">&nbsp;</td>
        <td bgcolor="#CCCCCC">&nbsp;</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">&nbsp;</td>
        <td bgcolor="#CCCCCC">&nbsp;</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
ผู้ดูแลระบบ MindPHP
โพสต์: 41384
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

มันไม่รู้จัก 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
oatgamess
PHP Jr. Member
PHP Jr. Member
โพสต์: 17
ลงทะเบียนเมื่อ: 13/08/2012 11:57 pm

Re: รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ

โพสต์ที่ยังไม่ได้อ่าน โดย oatgamess »

ยัง งง อยู่ครับ เพราะ 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'
HurricaneCyber
PHP Full Member
PHP Full Member
โพสต์: 33
ลงทะเบียนเมื่อ: 27/08/2012 1:22 pm

Re: รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ

โพสต์ที่ยังไม่ได้อ่าน โดย HurricaneCyber »

$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;
oatgamess
PHP Jr. Member
PHP Jr. Member
โพสต์: 17
ลงทะเบียนเมื่อ: 13/08/2012 11:57 pm

Re: รบกวนครับ เช็คล๊อคอินแล้วหาฟอมไม่เจอครับ

โพสต์ที่ยังไม่ได้อ่าน โดย oatgamess »

ได้ละครับ เป็นเพราะ `user` จิงๆ พอเอาออกละใส่ได้และครับ ขอบคุณครับ
ตอบกลับโพส

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: Baidu [Spider] และบุคลทั่วไป 143