|  |  | 
          
            | คือว่าผมเขียน หน้าบทความ เวลาป้อนข้อมูลทั้งหมดลงไปแล้วกดส่ง จะมีหัวข้อ q_topic, q_messge, q_name, q_email  ไม่เขียนข้อมูลลงฐานข้อมูล (ฐานข้อมูลจริง) แต่ว่าผมเอามาใช้กับ AppServ ที่ลงใว้ในเครื่องของผม มันเขียนลงฐานข้อมูลลงไปปกติ    ผมก็ไม่รู้ว่าเป็นเพราะอะไร ทำไมถึงเอามาใช้กับเซอเวอร์จริงไม่ได้ครับ หรือว่าผมเขียนตรงไหนผิด  ผมจึงขอความช่วยเหลือผู้รู้ด้วยครับ ขอบคุณล่วงหน้าครับ
 หน้าป้อนบทความ inputform.html
 
 Code (PHP)
 
 <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> </title>
</head>
   <body>
<table  align="center" border="0" bordercolor="0" cellpadding="0" cellspacing="0" width="98%">
<tbody><tr >                         
<td bgcolor="#ffffff">
<form method="POST" action="writequestion.php" align="center" >
<div align="left">
<p><b><big><br>
<font size="2" face="MS Sans Serif, Tahoma, sans-serif">
                <font size="4"> 
</font></font></big></b>
<big><center><font size="2" face="MS Sans Serif, Tahoma, sans-serif">|
<a href="inputform.html"> โพสประเดนข่าวใหม่ </a>| <a href="readwboard.php"> อ่านหัวข้อทั้งหมด </a> | </font></center></big><b><big>
</big></b></p>
</div>
<table border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="101"><div align="right"><strong>เรื่อง  </strong></div></td>
<td width="446"><input type="text" name="q_topic" size="66"></td>
</tr>
<tr>
<td valign="top"><div align="right"><strong>รายละเอียด  </strong></div></td>
<td><textarea rows="8" name="q_message"cols="100"></textarea></td>
</tr>
<tr>
<td><div align="right"><strong>ชื่อ  </strong></div></td>
<td><input type="text" name="q_name" size="29"></td>
</tr>
<tr>
<td><div align="right"><strong>Email </strong></div></td>
<td><input type="text" name="q_email" size="29"></td>
</tr>
</table>
<p align="center">
<input type="submit" value=" ส่ง " name="B1">
 
<input type="reset" value="เริ่มใหม่" name="B2">
</p>
</form>
</td>
                         </tr>  
                   </tbody></table> 
</body> </html>
 หน้าเขียนลงฐาน writequestion.php
 
 Code (PHP)
 
  <?php
    $hostname="localhost";
    $user="  ";
    $password="  ";
    $dbname="  ";
    $tblname="question";
    mysql_connect($hostname, $user, $password) or die("ติดต่อฐานข้อมูลไม่ได้");
    mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
 
    $q_ip=$REMOTE_ADDR ;
    $q_message = htmlspecialchars($q_message);
    $q_name = htmlspecialchars($q_name);
    $q_email = htmlspecialchars($q_email);
    $q_message = nl2br($q_message);
    $q_message = addslashes($q_message);
    $q_name = addslashes($q_name);
    $q_email = addslashes($q_email);
    $a = date("j"); // วันที่
    $b = strftime("%B"); // เดือนเต็ม
    $c = strftime("%Y")+543; // ปี พ.ศ.
    $d = date("H:i:s"); // เวลา
    $q_date = "$a $b $c - $d";
    $sql = "insert into question (q_id, q_topic, q_message, q_name, q_email, q_ip, q_datetime)
    values ('0','$q_topic','$q_message','$q_name','$q_email','$q_ip','$q_date')";
    $result = mysql_db_query($dbname, $sql);
    if (!$result) {
         echo("เอ็กซิคิวต์คำสั่ง SQL ไม่ได้ " . mysql_error() );
         exit;
    }
    else {
         echo "<center><font size=3>บันทึกข้อมูลเรียบร้อยแล้ว <br>";
         echo "<a href=\"readwboard.php\"> คลิกที่นี่เพื่อดูกระทู้ของคุณ </a></Font></center>";
    }
    ?>
 
 
 Tag : PHP, MySQL, HTML/CSS, JavaScript
 
 
 |  
            | 
 ประวัติการแก้ไข
 2011-09-30 00:31:44
 |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2011-09-30 00:29:10 | By :
                          superdong | View :
                          883 | Reply :
                          4 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |