|
 |
|
ช่วย แนะนำการกำหนด Condition ด้วยครับพี่ๆๆๆๆค้าบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
ob_start();
include "check_login.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>
</head>
<body>
<table align="center" cellpadding="0" cellspacing="0" border="1">
<tr>
<td colspan="2">
<?php
include "header.html";
?>
</td>
</tr>
<tr>
<td>
<?php
include "leftmenu.html";
?>
</td>
<td>
<?php
$Customers=$_REQUEST[Customers];
$Sent_Schedule=date('d-F-Y');
$Emp_Name=$_SESSION[user];
//----------------------------------------------------------------------------------------------------------------------------
if(copy($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]))
{
echo "Copy/Upload Complete<br>";
//*** Insert Record ***//
include "../include/connect_db.php";
$objDB = mysql_select_db("slc");
$strSQL = "INSERT INTO files ";
$strSQL .="(FilesName, Customers, Sent_Schedule, Emp_Name ) VALUES ('".$_FILES["filUpload"]["name"]."', '".$Customers."', '".$Sent_Schedule."', '".$Emp_Name."')";
$objQuery = mysql_query($strSQL);
}
?>
</td>
</tr>
<tr>
<td colspan="2">
<?php
include "footer.html";
?>
</td>
</tr>
</table>
</body>
</html>
ถ้าทำแบบนี้ ก็ เพิ่มข้อมมูลได้ ปกติครับ
แต่ผมอยากจะ เพิ่มเงื่อนไขก่อนบันทึกข้อมูล เช่น Capcha ครับ
พอดีทำ Capcha แล้ว อยากจะเอามาตรวจสอบก่อนว่าถ้า Capcha ถูกต้อง แล้ว ก็มาตรวจสอบว่าข้อมูลที่ส่งมา ว่างเปล่าหรือไม่ครับ
*************************************************************************************************************************************************
นี้คือ Code ที่ผมลอง เพิ่มเงื่อนไขเข้าไปครับ แต่ไม่สามารถเพิ่มข้อมูลลงใน ฐานข้อมูลได้
รบกวน พี่ๆ นะนำด้วยครับผม
Code (PHP)
<?php
ob_start();
include "check_login.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>
</head>
<body>
<table align="center" cellpadding="0" cellspacing="0" border="1">
<tr>
<td colspan="2">
<?php
include "header.html";
?>
</td>
</tr>
<tr>
<td>
<?php
include "leftmenu.html";
?>
</td>
<td>
<?php
$Customers=$_REQUEST[Customers];
$Sent_Schedule=date('d-F-Y');
$Emp_Name=$_SESSION[user];
//----------------------------------------------------------------------------------------------------------------------------
if($_SESSION[MyKey]==$strCheck){
copy($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]))
//*** Insert Record ***//
include "../include/connect_db.php";
$objDB = mysql_select_db("slc");
$strSQL = "INSERT INTO files ";
$strSQL .="(FilesName, Customers, Sent_Schedule, Emp_Name ) VALUES ('".$_FILES["filUpload"]["name"]."', '".$Customers."', '".$Sent_Schedule."', '".$Emp_Name."')";
$objQuery = mysql_query($strSQL);
}
?>
</td>
</tr>
<tr>
<td colspan="2">
<?php
include "footer.html";
?>
</td>
</tr>
</table>
</body>
</html>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2010-09-15 18:46:23 |
By :
popnakub |
View :
793 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
if($_SESSION[MyKey]==$strCheck){ ตัวแปร $strCheck มาถูกต้องไหมครับ
ตรวจดูว่ามันเข้า loop if หรือยัง เช่น ให้มัน echo อะไรบางอย่างออกมาเฉยๆก่อน
เท่าที่ดู
$Customers=$_REQUEST[Customers]; น่าจะมีเครื่องหมายคำพูด ??
32.
$Emp_Name=$_SESSION[user]; น่าจะมีเครื่องหมายคำพูด ??
ลองให้ มัน echo $strSQL ออกมาตรวจดูดีไหมครับ แล้วลองก็อบ ไปรันเองใน phpMyAdmin ดูว่าเข้าไหม หรือมี error อะไร
|
 |
 |
 |
 |
Date :
2010-09-15 20:22:08 |
By :
สกล |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ จะลอง ดูนะครับผม
|
 |
 |
 |
 |
Date :
2010-09-16 13:43:12 |
By :
popnakub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|