|
 |
|
ชื่อไฟล์ txt ไม่ขึ้นคะ ใครรู้วิธีแก้ ช่วยตอบหน่อยนะคะ |
|
 |
|
|
 |
 |
|
*** เพิ่มอีกนิดคะ ***
เวลาลูกค้าคนนึง จองไปแล้ว พออีกคนมาจอง ใส่ข้อมุลไป แล้วมันไม่สร้างเป็นไฟล์ txt ใหม่อ่ะคะ
มันต่อกันในไฟล์เดียวเลย
ไม่เข้าใจเหมือนกันทำไมเป็นแบบนี้ ที่ทำตอน Register ก็ไม่เป็นนะคะ ทั้งที่ code แทบจะเหมือนกันหมด
ช่วยตอบด้วยนะคร๊า ขอบคุณล่วงหน้าค่า.... ^o^
|
 |
 |
 |
 |
Date :
2009-05-08 18:57:56 |
By :
nattynaru |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$FirstName
มาจากไหนครับ ถ้า $FirstName ไม่มีค่า มันก็ย่อมเป็น .txt เฉยๆ
|
 |
 |
 |
 |
Date :
2009-05-08 19:34:36 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้า มันไม่มีค่า มันก้อต้องไม่ขึ้นข้อมูลในไฟล์.txt ด้วยสิคะ
แต่นี่ มันขึ้นน่ะคะ แต่ดันไม่ขึ้นเฉพาะ ชื่อไฟล์
|
 |
 |
 |
 |
Date :
2009-05-08 20:04:26 |
By :
nattynaru |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$FirstName ตอนที่คุณนำมาต่อเพื่อสร้างชื่อไฟล์ครับ
$BookFolder = $Dir . $FirstName . ".txt";
เนี้ยอะครับคุณยังไม่ได้รับ ค่าจาก form มาใส่ในตัวแปลอะครับทำให้ $FirstName เป็นค่าว่างอยู่อะครับ น่าจะแก้เป็น
Code (PHP)
<?php
<?php
session_start();
// Check If session available
if (isset($_SESSION['userName']) &&
isset($_SESSION['password']))
{
$UserName = $_SESSION['userName'];
$Password = $_SESSION['password'];
$FirstName = $_POST['fname'];
$LastName = $_POST['lname'];
$DateBook = $_POST['datebook'];
$Time = $_POST['time'];
$GuestNum = $_POST['guest_num'];
$Dir = "Booking/";
if (!file_exists($Dir)) //Check if file not exists.
mkdir($Dir, 0777); //Create books directory.
$BookFolder = $Dir . $FirstName . ".txt";
$Booking = fopen($BookFolder, "a+");
chmod ($Dir . $FirstName . ".txt", 0777);
if (is_writable($BookFolder)) {
if (fwrite($Booking, $DateBook . "\n" . $FirstName . "\n" .
$LastName . "\n" . $Time . "\n" . $GuestNum . "\n")) {
echo "<p>Booking Completed. Thank you for choosing Taley Restaurant.<br/>
<form action='menu.html'method='post'>
<input type ='hidden' name ='userName' value ='$UserName'/>
<input type ='hidden' name ='password' value ='$Password'/>
<input type ='hidden' name ='PHPSESSID' value ='<?php echo session_id() ?>'/>
<input type='submit' value='Menus page'/></form></p>";
fclose($Booking);
}
else
echo "<p>cannot write record to file.</p>";
}
}
else {
echo "you have to <br/><a href='cust_login.html'>Log in</a>";
}
?>
?>
น่าจะได้นะครับ
|
 |
 |
 |
 |
Date :
2009-05-09 01:54:17 |
By :
sangsood7 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|