Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > พี่ๆๆช่วยดู code สมัครสมาชิกให้หน่อยครับ มันบันทึกลงDBได้ทุกอย่างยกเว้นอัพโหลดรูป ช่วยหน่อยครับ



 

พี่ๆๆช่วยดู code สมัครสมาชิกให้หน่อยครับ มันบันทึกลงDBได้ทุกอย่างยกเว้นอัพโหลดรูป ช่วยหน่อยครับ

 



Topic : 081210



โพสกระทู้ ( 34 )
บทความ ( 0 )



สถานะออฟไลน์




อันนี้ตอนรัน

อันนี้หน้าโค้ด register
Code (PHP)
<?php require_once('../Connections/fishinghouse.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;
}
}

$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 (mem_name, mem_password, mem_email, mem_display, mem_rod, mem_reel, mem_other) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['mem_name'], "text"),
                       GetSQLValueString($_POST['mem_password'], "text"),
                       GetSQLValueString($_POST['mem_email'], "text"),
                       GetSQLValueString($_POST['mem_display'], "text"),
                       GetSQLValueString($_POST['mem_rod'], "text"),
                       GetSQLValueString($_POST['mem_reel'], "text"),
                       GetSQLValueString($_POST['mem_other'], "text"));

  mysql_select_db($database_fishinghouse, $fishinghouse);
  mysql_query("SET NAMES utf8");
  $Result1 = mysql_query($insertSQL, $fishinghouse) or die(mysql_error());

  $insertGoTo = "index.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>
<style type="text/css">
<!--
.style1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size: x-large;
}
.style7 {color: #666666}
.style8 {color: #FF0000}
.style9 {color: #FF0000; font-weight: bold; }
body {
	background-image: url(images/crop-13177241270092.jpg);
	margin-left: 200px;
	margin-top: 60px;
}
-->
</style>
</head>

<body>
<table width="916" height="39" border="0" align="center">
  <tr>
    <td bgcolor="#0D0D0D"> <div align="center" class="style1">Register</div></td>
  </tr>
</table>
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">
  <table width="936" border="0" align="center" bgcolor="#CCCCCC">
    <tr>
      <th width="448" valign="top"><div align="right">เงื่อนไขในการสมัครสมาิชิก:</div></th>
      <td width="478"><label>1.   ข้าพเจ้าจะรักษาบรรยากาศการแลกเปลี่ยนความเห็นที่ดี  <br />
      2.   ข้าพเจ้าจะปฎิบัติตามข้อกำหนด/คำแนะนำที่ระบุไว้ ก่อนแสดงความเห็นทุกครั้ง  </label></td>
    </tr>
    <tr>
      <td><div align="right">ชื่อ (name):</div></td>
      <td><label>
        <input name="mem_name" type="text" id="mem_name" size="35" maxlength="15" />
      <span class="style7">* ความยาวไม่เกิน 4-15 ตัวอักษร</span></label></td>
    </tr>
    <tr>
      <td><div align="right">รหัสผ่าน  (password):</div></td>
      <td><label>
        <input name="mem_password" type="password" id="mem_password" maxlength="15" />
      <span class="style7">* ความยาวไม่เกิน 4-15 ตัวอักษร</span></label></td>
    </tr>
    <tr>
      <td valign="top"><div align="right">รูปประจำตัว (display):</div></td>
      <td><label>
        <input type="file" name="mem_display" id="mem_display" />
        <br />
        <span class="style7">-รับเฉพาะไฟล์ jpgและgif เท่านั้น</span><br />
        <span class="style7">-</span><span class="style8">เลือกรูปภาพที่เหมาะสมเท่านั้น</span><br />
        <span class="style7">-ขนาดรูปไม่เกิน 200k</span></label></td>
    </tr>
    <tr>
      <td><div align="right">E-Mail:</div></td>
      <td><label>
        <input name="mem_email" type="text" id="mem_email" size="35" maxlength="30" />
      <span class="style7">*เเนะนำให้ใช้ hotmail</span></label></td>
    </tr>
    <tr>
      <td><div align="right">คันเบ๊ด (Rod):</div></td>
      <td><label>
        <input name="mem_rod" type="text" id="mem_rod" size="38" maxlength="20" />
      <span class="style7">* ความยาวไม่เกิน 20 อักษร</span></label></td>
    </tr>
    <tr>
      <td><div align="right">รอก (Reel):</div></td>
      <td><label>
        <input name="mem_reel" type="text" id="mem_reel" size="38" maxlength="20" />
      <span class="style7">* ความยาวไม่เกิน 20 อักษร</span></label></td>
    </tr>
    <tr>
      <td valign="top"><div align="right">อื่นๆ (other):</div></td>
      <td><label>
        <textarea name="mem_other" id="mem_other" cols="45" rows="5"></textarea>
      </label></td>
    </tr>
    <tr>
      <td colspan="2"> <div align="center" class="style9">ข้าพเจ้ายอมรับเงื่อนไขทุกประการ</div></td>
    </tr>
    <tr>
      <td>
        <label>
        
        <div align="right">
          <input type="submit" name="button" id="button" value="ยอมรับและส่งข้อมูล" />
        </div>
      </label></td>
      <td><label>
        
        <div align="left">
          <input type="reset" name="button2" id="button2" value="ยกเลิก" />
        </div>
      </label></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>



อันนี้หน้า upload.php
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>Untitled Document</title>
</head>

<body>
<?
if ($memdisplay!=""){
if(strchr($memdisplay_name,".")==".jpg"|| strchr($memdisplay_name,".")==".JPG"|| 
strchr($memdisplay_name,".")==".gif")
{
copy($memdisplay,"images/".$memdisplay_name);
$img="images/".$memdisplay_name;
$hostname_fishinghouse = "localhost";
$database_fishinghouse = "fishing house";
$username_fishinghouse = "root";
$password_fishinghouse = "1234";
$result=mysql_connect($hostname,$username_fishinghouse,$password_fishinghouse);
if($result){
$sql="INSERT INTO member(mem_ID,mem_display)VALUES(','$images')";
echo"path ที่ถูกบันทึกลงตารางคือ".$images;
mysql_db_query($username_fishinghouse,$sql);
}
}else{
echo"รูปแบบไฟล์ผิดพลาด ไฟล์ที่คุณเลือกไม่ใช่ไฟล์รูปที่กำหนด";
}}?>

</body>
<!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>
</head>

<body>
<?
if ($memdisplay!=""){
if(strchr($memdisplay_name,".")==".jpg"|| strchr($memdisplay_name,".")==".JPG"|| 
strchr($memdisplay_name,".")==".gif")
{
copy($memdisplay,"images/".$memdisplay_name);
$img="images/".$memdisplay_name;
$hostname_fishinghouse = "localhost";
$database_fishinghouse = "fishing house";
$username_fishinghouse = "root";
$password_fishinghouse = "1234";
$result=mysql_connect($hostname,$username_fishinghouse,$password_fishinghouse);
if($result){
$sql="INSERT INTO member(mem_ID,mem_display)VALUES(','$images')";
echo"path ที่ถูกบันทึกลงตารางคือ".$images;
mysql_db_query($username_fishinghouse,$sql);
}
}else{
echo"รูปแบบไฟล์ผิดพลาด ไฟล์ที่คุณเลือกไม่ใช่ไฟล์รูปที่กำหนด";
}}?>

</body>
</html>


มันสามารถบันทึกทุกอย่างลง db ได้แต่มัน ไม่บันทึกชื่อไฟล์ภาพอ่ะครับ (ผมอยากให้มันเก็บชื่อลงdb แล้วกอ๊ปภาพลงโฟเดอร์อ่ะครับ)
ผมแก้เป็น10รอบแล้วก็ยังไม่ได้สักที่ครับ พี่ๆช่วยเช๊คให้หน่อยครับว่าผิดอย่างไง ถ้าแก้ให้ด้วยจะขอบคุณมากครับ



Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-07-17 23:57:12 By : thisbank View : 1164 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Quote:
$_POST['mem_display']


จะต้องอ่านแบบ $_FILES ครับ ดูตัวอย่างนี้ครับ

Code (PHP)
<?
	if(move_uploaded_file($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]))
	{
		echo "Copy/Upload Complete<br>";

		//*** Insert Record ***//
		$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
		$objDB = mysql_select_db("mydatabase");
		$strSQL = "INSERT INTO files ";
		$strSQL .="(Name,FilesName) VALUES ('".$_POST["txtName"]."','".$_FILES["filUpload"]["name"]."')";
		$objQuery = mysql_query($strSQL);		
	}
?>







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-18 06:04:38 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : พี่ๆๆช่วยดู code สมัครสมาชิกให้หน่อยครับ มันบันทึกลงDBได้ทุกอย่างยกเว้นอัพโหลดรูป ช่วยหน่อยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่