<?php $hostname_contact_conn = "127.0.0.1"; $database_contact_conn = "guestbook"; $username_contact_conn = "user"; $password_contact_conn = "123456";
$contact_conn = mysql_pconnect($hostname_contact_conn, $username_contact_conn, $password_contact_conn) or trigger_error(mysql_error(),E_USER_ERROR);
$db_selected = mysql_select_db ('test' , $contact_conn ) or die ( 'Can\'t use the database : ' . mysql_error() ) ;
mysql_query("SET NAMES 'utf8'"); mysql_query('SET CHARACTER_SET_CLIENT=utf8'); mysql_query('SET CHARACTER_SET_RESULTS=utf8'); mysql_query('SET default-character-set=utf8');
session_start() ; // php.ini 內的 output_buffering 要設成 4096,以免產生錯誤
date_default_timezone_set( "Asia/Taipei" ) ; ?> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/> <?php // echo $_REQUEST['guest_name'] . "<br />" ;
if( $_REQUEST['guest_name'] ) { $insertSQL = sprintf("INSERT INTO guestbook (`name`, `email`, `datetime`, `comment`) VALUES ('%s', '%s', '%s', '%s')", iconv('big5','utf-8',$_REQUEST['guest_name']) , $_REQUEST['guest_email'] , date("Y-m-d H:i:s") , iconv('big5','utf-8',$_REQUEST['guest_comment']) ) ;
echo "<br />" . $insertSQL . "<br />" ; $result = mysql_query($insertSQL) or die("<b>error</b>: failed to execute query <i>$query</i>");
mysql_close($contact_conn);
//$desiredContent = mysql_fetch_array($result, MYSQL_ASSOC);
//mysql_free_result($result);
print "response : saved."; } ?>
|