<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4940864674009916360</id><updated>2025-06-22T03:00:11.961+07:00</updated><category term="PHP"/><category term="javascript"/><category term="css"/><category term="Google Maps API V.2"/><category term="ajax"/><category term="สารบัญ"/><title type='text'>PHP,code php,โค้ด php,บทความ php</title><subtitle type='html'>code php, โค้ด php, ภาษา php, บทความ php, เขียน php, free php script, php ajax, php script, html code</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>89</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-8704870384106695024</id><published>2012-08-22T15:23:00.002+07:00</published><updated>2012-08-22T15:23:38.420+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>การสั่งให้ textfield จำค่าที่กรอกข้อมูลไว้ตลอด</title><content type='html'>&lt;br /&gt;
เป็นการใช้&lt;b&gt;โค้ด&lt;/b&gt; javascript เพื่อเรียกใช้งาน Cookie ในการจำค่าที่เรากรอกในช่อง textfield ลักษณะการทำงานของ &lt;b&gt;code&lt;/b&gt; ก็คือเมื่อกรอกข้อมูลใน textfield แล้วกดปุ่ม submit ค่าที่เรากรอกก็จะถูกบันทึกไว้ และแสดงค่าใน textfield ตลอด ไม่ว่าเราจะ refresh กี่ครั้ง ข้อมูลก็จะยังอยู่ จนกว่าเราจะบันทึกข้อมูลใหม่ลงไปข้อมูลถึงจะเปลี่ยน โดย Cookie ตัวนี้ผมตั้งไว้ที่ 60 วันน่ะครับ ลองนำไปใช้ดู&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;ตัวอย่างโค้ด&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/***********************************************&lt;br /&gt;
* Remember Text INPUT field values- by JavaScriptKit.com&lt;br /&gt;
* This notice MUST stay intact for use&lt;br /&gt;
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and more&lt;br /&gt;
***********************************************/&lt;br /&gt;
&lt;br /&gt;
var remembervalues_days=&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;60&lt;/b&gt;&lt;/span&gt; //Remember text input values for how many days?&lt;br /&gt;
var dyncookiename=encodeURI(window.location.pathname) //Name of cookie. Changes depending on the page.&lt;br /&gt;
&lt;br /&gt;
var recallinput=function(){&lt;br /&gt;
var cookienamevalue=rememberinput.getCookie(dyncookiename).split(&quot;##&quot;)&lt;br /&gt;
for (var i=0; i&amp;lt;cookienamevalue.length; i++){&lt;br /&gt;
var cookiename=cookienamevalue[i].split(&quot;#&quot;)[0]&lt;br /&gt;
var cookievalue=cookienamevalue[i].split(&quot;#&quot;)[1]&lt;br /&gt;
if (document.getElementById(cookiename)!=null &amp;amp;&amp;amp; document.getElementById(cookiename).type==&quot;text&quot;) //if this text field has a stored value&lt;br /&gt;
document.getElementById(cookiename).value=decodeURI(cookievalue)&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var rememberinput=function(){&lt;br /&gt;
var rememberit=&quot;&quot;&lt;br /&gt;
for (var i=0; i&amp;lt;arguments.length; i++){&lt;br /&gt;
if (document.getElementById(arguments[i]).type==&quot;text&quot; &amp;amp;&amp;amp; document.getElementById(arguments[i]).value!=&quot;&quot;) //if this is a form text INPUT and not empty&lt;br /&gt;
rememberit+=arguments[i]+&quot;#&quot;+encodeURI(document.getElementById(arguments[i]).value)+&quot;##&quot;&lt;br /&gt;
}&lt;br /&gt;
rememberinput.setCookie(dyncookiename, rememberit, remembervalues_days)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
rememberinput.getCookie=function(Name){ //get cookie value&lt;br /&gt;
var re=new RegExp(Name+&quot;=[^;]+&quot;, &quot;i&quot;); //construct RE to search for target name/value pair&lt;br /&gt;
if (document.cookie.match(re)) //if cookie found&lt;br /&gt;
return document.cookie.match(re)[0].split(&quot;=&quot;)[1] //return its value&lt;br /&gt;
return &quot;&quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
rememberinput.setCookie=function(name, value, days){ //set cookie value&lt;br /&gt;
var expireDate = new Date()&lt;br /&gt;
//set &quot;expstring&quot; to either future or past date, to set or delete cookie, respectively&lt;br /&gt;
var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))&lt;br /&gt;
document.cookie = name+&quot;=&quot;+value+&quot;; expires=&quot;+expireDate.toGMTString()+&quot;;&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if (window.addEventListener)&lt;br /&gt;
window.addEventListener(&quot;load&quot;, recallinput, false)&lt;br /&gt;
else if (window.attachEvent)&lt;br /&gt;
window.attachEvent(&quot;onload&quot;, recallinput)&lt;br /&gt;
else if (document.getElementById)&lt;br /&gt;
window.onload=recallinput&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;form onSubmit=&quot;rememberinput(&#39;yourname&#39;, &#39;youremail&#39;)&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Name:*&amp;lt;br /&amp;gt;&amp;lt;input type=&quot;text&quot; id=&quot;yourname&quot; size=&quot;25&quot; /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Email Address:*&amp;lt;br /&amp;gt;&amp;lt;input type=&quot;text&quot; id=&quot;youremail&quot; size=&quot;25&quot; /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Feedback:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;textarea cols=&quot;25&quot; rows=&quot;6&quot;&amp;gt;&amp;lt;/textarea&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/8704870384106695024/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/8704870384106695024' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/8704870384106695024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/8704870384106695024'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/08/textfield.html' title='การสั่งให้ textfield จำค่าที่กรอกข้อมูลไว้ตลอด'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-3796599318260268949</id><published>2012-08-22T09:45:00.001+07:00</published><updated>2012-08-22T09:45:27.779+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>ตัวอย่างฟอร์มการกรอกข้อมูลส่วนตัวโดยใช้ code php</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
จากบทความ&amp;nbsp;&lt;a class=&quot;GKY2L2ICPB&quot; href=&quot;http://hotcodephp.blogspot.com/2012/08/javascript.html&quot; style=&quot;border: 0px; color: #1155cc; cursor: pointer; font-family: Arial, Helvetica, sans-serif; font-size: 13px; margin: 0px 10px 0px 0px; padding: 0px; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;ตัวอย่างฟอร์มการกรอกข้อมูลส่วนตัวโดยใช้ Javascript&lt;/a&gt;&amp;nbsp;ผมได้เขียนถึงการกรอกข้อมูลในแบบฟอร์มโดยใช้&lt;b&gt;โค้ด php + javascript &lt;/b&gt;มาบทความนี้เลยขอกล่าวถึงการใช้เฉพาะ&lt;b&gt;โค้ด php&lt;/b&gt; อย่างเดียวบ้าง ซึ่งมันก็ดูดีไปอีกแบบ ลักษณะการทำงานก็เหมือนเดิมคือเวลากรอกข้อมูลผิด หรือกรอกไม่ครบถ้วนก็จะมีข้อความเตือนขึ้นมา มาดูตัวอย่างกันครับ&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp50HbjJd6lJR9aLCrOMjbkEJAPiNb3kmrETE0X2xvfha-s4SHEMXTmECpP1-6n7fuAr7xQFb_8feiHp0mwl7WjliakzD1Uv37Hkt8ncSLKyWzgvykrh-p70k31pSZ5PiyEpejRrTf1HFL/s1600/from1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp50HbjJd6lJR9aLCrOMjbkEJAPiNb3kmrETE0X2xvfha-s4SHEMXTmECpP1-6n7fuAr7xQFb_8feiHp0mwl7WjliakzD1Uv37Hkt8ncSLKyWzgvykrh-p70k31pSZ5PiyEpejRrTf1HFL/s1600/from1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
ตัวอย่างโค้ด simple2.php&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp;&amp;lt;!DOCTYPE html PUBLIC&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;html&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;head&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;title&amp;gt;Sample 2&amp;lt;/title&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;style&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
body { padding: 10px 0px 0px 0px; }&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
td&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
{&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; padding: 2px 5px;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; text-align: left;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
h4 { margin: 0px; }&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
input.editfield, select.editfield, textarea.editfield { width: 18em; }&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/style&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/head&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;body&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;center&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;form method=&quot;post&quot; action=&quot;sample2.php&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;input type=&quot;hidden&quot; name=&quot;form_validation_rules&quot; &amp;nbsp; &amp;nbsp; &amp;nbsp;value=&quot;&quot; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;input type=&quot;hidden&quot; name=&quot;form_validation_behaviours&quot; value=&quot;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
Details : count details_count 20 black red;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
Year : next 4;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
Month Day : next 2;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
Month Day : prev;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&quot; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;table&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;?php&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
if (isset($_POST[&#39;submit&#39;]))&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
{&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; include &#39;form-validation.php&#39;;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; $result = form_validation_validate($_POST, &quot;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Username Password Year Month Day Details : empty;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Username Password : len &amp;gt;= 3;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Username Password : chnum_;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; E-mail: email;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Membership : select 0;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Year : &amp;gt; 1900;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Year Month Day : date;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Sex : radio;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Details: len &amp;lt;= 20;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Categories[] Newsletters[] : cnt &amp;gt;= 2;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Agree : terms;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; ?&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td colspan=&quot;2&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;?php&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; if ($result === true)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; echo &#39;&amp;lt;span style=&quot;color: green;&quot;&amp;gt;The form is successfully submitted!&amp;lt;/span&amp;gt;&#39;;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; $_POST = Array();&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; }&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; else echo &#39;&amp;lt;span style=&quot;color: red;&quot;&amp;gt;&#39; . $result . &#39;&amp;lt;/span&amp;gt;&#39;;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; ?&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;?php&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
function __post($name, $val = &#39;&#39;)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
{&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; return isset($_POST[$name]) ? $_POST[$name] : $val;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
function __checked($name, $val)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
{&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; return isset($_POST[$name]) &amp;amp;&amp;amp; ($_POST[$name] == $val) &amp;nbsp;? &#39;checked=&quot;checked&quot;&#39; : &#39;&#39;;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
function __checked2($name, $ind)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
{&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; return isset($_POST[$name]) &amp;amp;&amp;amp; in_array($ind, $_POST[$name]) ? &#39;checked=&quot;checked&quot;&#39; : &#39;&#39;;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
function __selected($name, $val)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
{&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; return isset($_POST[$name]) &amp;amp;&amp;amp; ($_POST[$name] == $val) ? &#39;selected=&quot;selected&quot;&#39; : &#39;&#39;;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
function __selected2($name, $ind)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
{&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; return isset($_POST[$name]) &amp;amp;&amp;amp; in_array($ind, $_POST[$name]) ? &#39;selected=&quot;selected&quot;&#39; : &#39;&#39;;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
?&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td style=&quot;padding-bottom: 10px;&quot; colspan=&quot;2&quot;&amp;gt;&amp;lt;h4&amp;gt;Sample 2&amp;lt;/h4&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Username:&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input class=&quot;editfield&quot; type=&quot;text&quot; name=&quot;Username&quot; value=&quot;&amp;lt;?=__post(&#39;Username&#39;);?&amp;gt;&quot; /&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Password:&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input class=&quot;editfield&quot; type=&quot;password&quot; name=&quot;Password&quot; value=&quot;&amp;lt;?=__post(&#39;Password&#39;);?&amp;gt;&quot; /&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;E-mail:&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input class=&quot;editfield&quot; type=&quot;text&quot; name=&quot;E-mail&quot; value=&quot;&amp;lt;?=__post(&#39;E-mail&#39;);?&amp;gt;&quot; /&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Membership:&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;select class=&quot;editfield&quot; name=&quot;Membership&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;0&quot; &amp;lt;?=__selected(&#39;Membership&#39;, 0);?&amp;gt;&amp;gt;&amp;lt;/option&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;1&quot; &amp;lt;?=__selected(&#39;Membership&#39;, 1);?&amp;gt;&amp;gt;Silver&amp;lt;/option&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;2&quot; &amp;lt;?=__selected(&#39;Membership&#39;, 2);?&amp;gt;&amp;gt;Gold&amp;lt;/option&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;3&quot; &amp;lt;?=__selected(&#39;Membership&#39;, 3);?&amp;gt;&amp;gt;Platinum&amp;lt;/option&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/select&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Age:&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;input type=&quot;text&quot; name=&quot;Year&quot; &amp;nbsp;value=&quot;&amp;lt;?=__post(&#39;Year&#39;); ?&amp;gt;&quot; size=&quot;4&quot; maxlength=&quot;4&quot; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;input type=&quot;text&quot; name=&quot;Month&quot; value=&quot;&amp;lt;?=__post(&#39;Month&#39;);?&amp;gt;&quot; size=&quot;2&quot; maxlength=&quot;2&quot; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;input type=&quot;text&quot; name=&quot;Day&quot; &amp;nbsp; value=&quot;&amp;lt;?=__post(&#39;Day&#39;); &amp;nbsp;?&amp;gt;&quot; size=&quot;2&quot; maxlength=&quot;2&quot; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;small&amp;gt;yyyy/mm/dd&amp;lt;/small&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Sex:&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;input type=&quot;radio&quot; name=&quot;Sex&quot; value=&quot;male&quot; &amp;nbsp; &amp;lt;?=__checked(&#39;Sex&#39;, &#39;male&#39; &amp;nbsp;);?&amp;gt; /&amp;gt; Male&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;input type=&quot;radio&quot; name=&quot;Sex&quot; value=&quot;female&quot; &amp;lt;?=__checked(&#39;Sex&#39;, &#39;female&#39;);?&amp;gt; /&amp;gt; Female&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Details:&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;textarea class=&quot;editfield&quot; name=&quot;Details&quot; rows=&quot;4&quot;&amp;gt;&amp;lt;?=__post(&#39;Details&#39;);?&amp;gt;&amp;lt;/textarea&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;br /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;small&amp;gt;&amp;lt;span id=&quot;details_count&quot;&amp;gt;0&amp;lt;/span&amp;gt; out of 20 characters&amp;lt;/small&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Categories:&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;select class=&quot;editfield&quot; name=&quot;Categories[]&quot; multiple=&quot;multiple&quot; size=&quot;4&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;0&quot; &amp;lt;?=__selected2(&#39;Categories&#39;, 0);?&amp;gt;&amp;gt;Cars&amp;lt;/option&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;1&quot; &amp;lt;?=__selected2(&#39;Categories&#39;, 1);?&amp;gt;&amp;gt;Computers&amp;lt;/option&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;2&quot; &amp;lt;?=__selected2(&#39;Categories&#39;, 2);?&amp;gt;&amp;gt;Dogs&amp;lt;/option&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;3&quot; &amp;lt;?=__selected2(&#39;Categories&#39;, 3);?&amp;gt;&amp;gt;Food&amp;lt;/option&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/select&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;br /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;small&amp;gt;Use ctrl+mouse to select multiple categories&amp;lt;/small&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Newsletters:&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;input type=&quot;checkbox&quot; name=&quot;Newsletters[]&quot; value=&quot;0&quot; &amp;lt;?=__checked2(&#39;Newsletters&#39;, 0);?&amp;gt; /&amp;gt; Cars &amp;lt;br /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;input type=&quot;checkbox&quot; name=&quot;Newsletters[]&quot; value=&quot;1&quot; &amp;lt;?=__checked2(&#39;Newsletters&#39;, 1);?&amp;gt; /&amp;gt; Computers &amp;lt;br /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;input type=&quot;checkbox&quot; name=&quot;Newsletters[]&quot; value=&quot;2&quot; &amp;lt;?=__checked2(&#39;Newsletters&#39;, 2);?&amp;gt; /&amp;gt; Dogs &amp;lt;br /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;input type=&quot;checkbox&quot; name=&quot;Newsletters[]&quot; value=&quot;3&quot; &amp;lt;?=__checked2(&#39;Newsletters&#39;, 3);?&amp;gt; /&amp;gt; Food&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;input type=&quot;checkbox&quot; name=&quot;Agree&quot; value=&quot;Yes&quot; &amp;lt;?=__checked(&#39;Agree&#39;, &#39;Yes&#39;);?&amp;gt; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;small&amp;gt;By checking this box you agree to some terms&amp;lt;/small&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot; /&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/table&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/form&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;script src=&quot;form-validation.js&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/center&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/body&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/html&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
ส่วนอันนี้เป็นไฟล์ประกอบน่ะครับ&amp;nbsp;form-validation.js และ&amp;nbsp;form-validation.php &lt;a href=&quot;http://dl-2.one2up.com/onetwo/content/2012/8/22/f532713898ebe64150e364b6cdfe5aff.rar&quot; target=&quot;_blank&quot;&gt;download&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/3796599318260268949/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/3796599318260268949' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/3796599318260268949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/3796599318260268949'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/08/code-php.html' title='ตัวอย่างฟอร์มการกรอกข้อมูลส่วนตัวโดยใช้ code php'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp50HbjJd6lJR9aLCrOMjbkEJAPiNb3kmrETE0X2xvfha-s4SHEMXTmECpP1-6n7fuAr7xQFb_8feiHp0mwl7WjliakzD1Uv37Hkt8ncSLKyWzgvykrh-p70k31pSZ5PiyEpejRrTf1HFL/s72-c/from1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-9210729428295418994</id><published>2012-08-21T09:35:00.003+07:00</published><updated>2012-08-21T09:35:32.495+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>ตัวอย่างฟอร์มการกรอกข้อมูลส่วนตัวโดยใช้ Javascript เข้ามาช่วย</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;บทความ&lt;/b&gt;นี้เป็นตัวอย่างการทำฟอร์มไว้ใช้สำหรับกรอกข้อมูลประวัตส่วนตัว ซึ่งหลายท่านอาจเคยเห็นมาหลายแบบแล้ว แต่&lt;b&gt;โค้ด&lt;/b&gt;ที่ผมจะนำมาให้ดูนี้เป็นการใช้งานของ&lt;b&gt;โค้ด php + javascript&lt;/b&gt;&amp;nbsp;ซึ่งลักษณะการทำงานคือ เมื่อเรากรอกข้อมูลในฟอร์มแล้วหากกรอกไม่ครบถ้วน หรือกรอกไม่ถูกต้อง มีจะข้อความเตือนตลอด ซึ่งทำให้ง่ายต่อการกรอกข้อมูล มาดู &lt;b&gt;code&lt;/b&gt; กันเลยครับ&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaDba2n6KFM-f1m4USiqaIYdP8T3QFr00zp-Sq5yQRxoLLoxWALo-DcogEuOuKLloYTjeuTpKTdtuceb9E-yNVTjeg1Wd1obUz8_M-nzrizPR30MpAeA75nHVKK96Nn6GUpcpHmERfVJ-k/s1600/from.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaDba2n6KFM-f1m4USiqaIYdP8T3QFr00zp-Sq5yQRxoLLoxWALo-DcogEuOuKLloYTjeuTpKTdtuceb9E-yNVTjeg1Wd1obUz8_M-nzrizPR30MpAeA75nHVKK96Nn6GUpcpHmERfVJ-k/s400/from.jpg&quot; width=&quot;300&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
ตัวอย่าง code simple1.php&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!DOCTYPE html PUBLIC&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;title&amp;gt;Sample 1&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
body { padding: 10px 0px 0px 0px; }&lt;br /&gt;
td&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; padding: 2px 5px;&lt;br /&gt;
&amp;nbsp; text-align: left;&lt;br /&gt;
}&lt;br /&gt;
h4 { margin: 0px; }&lt;br /&gt;
input.editfield, select.editfield, textarea.editfield { width: 18em; }&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;form method=&quot;post&quot; action=&quot;sample1.php&quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&quot;hidden&quot; name=&quot;form_validation_rules&quot; value=&quot;&lt;br /&gt;
Username Password Year Month Day Details : empty;&lt;br /&gt;
Username Password : len &amp;gt;= 3;&lt;br /&gt;
Username Password : chnum_;&lt;br /&gt;
E-mail: email;&lt;br /&gt;
Membership : select 0;&lt;br /&gt;
Year : &amp;gt; 1900;&lt;br /&gt;
Year Month Day : date;&lt;br /&gt;
Sex : radio;&lt;br /&gt;
Details: len &amp;lt;= 20;&lt;br /&gt;
Categories[] Newsletters[] : cnt &amp;gt;= 2;&lt;br /&gt;
Agree : terms;&lt;br /&gt;
&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&quot;hidden&quot; name=&quot;form_validation_behaviours&quot; value=&quot;&lt;br /&gt;
Details : count details_count 20 black red;&lt;br /&gt;
Year : next 4;&lt;br /&gt;
Month Day : next 2;&lt;br /&gt;
Month Day : prev;&lt;br /&gt;
&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td style=&quot;padding-bottom: 10px;&quot; colspan=&quot;2&quot;&amp;gt;&amp;lt;h4&amp;gt;Sample 1&amp;lt;/h4&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Username:&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input class=&quot;editfield&quot; type=&quot;text&quot; name=&quot;Username&quot; /&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Password:&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input class=&quot;editfield&quot; type=&quot;password&quot; name=&quot;Password&quot; /&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;E-mail:&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input class=&quot;editfield&quot; type=&quot;text&quot; name=&quot;E-mail&quot; /&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Membership:&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;select class=&quot;editfield&quot; name=&quot;Membership&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;0&quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;1&quot;&amp;gt;Silver&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;2&quot;&amp;gt;Gold&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;3&quot;&amp;gt;Platinum&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/select&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Age:&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;input type=&quot;text&quot; name=&quot;Year&quot; &amp;nbsp;size=&quot;4&quot; maxlength=&quot;4&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;input type=&quot;text&quot; name=&quot;Month&quot; size=&quot;2&quot; maxlength=&quot;2&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;input type=&quot;text&quot; name=&quot;Day&quot; &amp;nbsp; size=&quot;2&quot; maxlength=&quot;2&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;small&amp;gt;yyyy/mm/dd&amp;lt;/small&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Sex:&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;input type=&quot;radio&quot; name=&quot;Sex&quot; value=&quot;male&quot; &amp;nbsp; /&amp;gt; Male&lt;br /&gt;
&amp;nbsp; &amp;lt;input type=&quot;radio&quot; name=&quot;Sex&quot; value=&quot;female&quot; /&amp;gt; Female&lt;br /&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Details:&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;textarea class=&quot;editfield&quot; name=&quot;Details&quot; rows=&quot;4&quot;&amp;gt;&amp;lt;/textarea&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;small&amp;gt;&amp;lt;span id=&quot;details_count&quot;&amp;gt;0&amp;lt;/span&amp;gt; out of 20 characters&amp;lt;/small&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Categories:&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;select class=&quot;editfield&quot; name=&quot;Categories[]&quot; multiple=&quot;multiple&quot; size=&quot;4&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;0&quot;&amp;gt;Cars&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;1&quot;&amp;gt;Computers&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;2&quot;&amp;gt;Dogs&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;3&quot;&amp;gt;Food&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/select&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;small&amp;gt;Use ctrl+mouse to select multiple categories&amp;lt;/small&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;Newsletters:&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;input type=&quot;checkbox&quot; name=&quot;Newsletters[]&quot; value=&quot;0&quot; /&amp;gt; Cars &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;input type=&quot;checkbox&quot; name=&quot;Newsletters[]&quot; value=&quot;1&quot; /&amp;gt; Computers &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;input type=&quot;checkbox&quot; name=&quot;Newsletters[]&quot; value=&quot;2&quot; /&amp;gt; Dogs &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;input type=&quot;checkbox&quot; name=&quot;Newsletters[]&quot; value=&quot;3&quot; /&amp;gt; Food&lt;br /&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;input type=&quot;checkbox&quot; name=&quot;Agree&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;small&amp;gt;By checking this box you agree to some terms&amp;lt;/small&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;script src=&quot;form-validation.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
ส่วนอันนี้เป็น&lt;b&gt;โค้ด&lt;/b&gt;&amp;nbsp;form-validation.js เป็นไฟล์ประกอบน่ะครับ &lt;a href=&quot;http://dl-13.one2up.com/onetwo/content/2012/8/21/d3dfdeb7b4768eef12ce37ee87df4f09.js&quot; target=&quot;_blank&quot;&gt;download&lt;/a&gt; ไปใช้กันได้เลย&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/9210729428295418994/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/9210729428295418994' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/9210729428295418994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/9210729428295418994'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/08/javascript.html' title='ตัวอย่างฟอร์มการกรอกข้อมูลส่วนตัวโดยใช้ Javascript เข้ามาช่วย'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaDba2n6KFM-f1m4USiqaIYdP8T3QFr00zp-Sq5yQRxoLLoxWALo-DcogEuOuKLloYTjeuTpKTdtuceb9E-yNVTjeg1Wd1obUz8_M-nzrizPR30MpAeA75nHVKK96Nn6GUpcpHmERfVJ-k/s72-c/from.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-2954879307862628814</id><published>2012-08-20T10:06:00.001+07:00</published><updated>2012-08-20T10:06:57.839+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>การทำหน้ารอระหว่างโหลดข้อมูล (preloader)</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
หลายท่านคงเคยเข้าเวปแล้วเจอหน้าที่บอกสถานะการโหลดหน้า webpage ก่อนที่จะเข้าหน้าเวปจริงใช่ไหมครับ วันนี้เรามาลองทำโดยใช้&lt;b&gt;โค้ด&lt;/b&gt; javascript เข้ามาช่วย ซึ่งลักษณะการทำงานของมันก็คือ เวลาเข้าเวปจะมีรูปขึ้นระหว่างรอโหลดหน้าเวป เมื่อรอสักพักก็จะเข้าหน้าเวปจริงเลย ซึ่งมีข้อดีมันจะไม่แสดง url ที่แท้จริงของหน้าเวปหลักของเรา มาดู&lt;b&gt;โค้ด&lt;/b&gt;ตัวอย่างกันครับ&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;code&lt;/b&gt; หน้า index.html&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;&lt;br /&gt;
&amp;nbsp;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;&lt;br /&gt;
&amp;lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;title&amp;gt;Ajax Preloader example&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;link href=&quot;style/style.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;max.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;body onload=&quot;loadSite();&quot; id=&quot;myBody&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;lt;div id=&quot;loader&quot;&amp;gt;&amp;lt;img src=&quot;loader.gif&quot; border=&quot;1&quot;/&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;รูปตัวอย่าง&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhirmiN9CetxlPjuACFJ4977omFR_JKfeHBWlCBWboGAD76ZZYM-Qr45XeLq3iE0gn7HIJbOb10pTRbF2QHftFPy6fnqCrWVgr3Y5S39kr68nrFhWJhds4wJ9mumnMLBGlNWUd8pilJPRRu/s1600/preload1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;235&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhirmiN9CetxlPjuACFJ4977omFR_JKfeHBWlCBWboGAD76ZZYM-Qr45XeLq3iE0gn7HIJbOb10pTRbF2QHftFPy6fnqCrWVgr3Y5S39kr68nrFhWJhds4wJ9mumnMLBGlNWUd8pilJPRRu/s400/preload1.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi30-DRmOFbY8UhFBKVuo8n-zdOaTtPTNHDMWErETAkOLaPepuhLXPllbkYxUFosMnVQJNiOxHnHkdF6-m7gbODDVC1LSCfIOelzidWPTwKscTBKsoh-XAzMPZpYPcqp1Jxi5xYhxozVfu/s1600/preload2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;127&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi30-DRmOFbY8UhFBKVuo8n-zdOaTtPTNHDMWErETAkOLaPepuhLXPllbkYxUFosMnVQJNiOxHnHkdF6-m7gbODDVC1LSCfIOelzidWPTwKscTBKsoh-XAzMPZpYPcqp1Jxi5xYhxozVfu/s400/preload2.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
ส่วนอันนี้เป็นไฟล์ตัวย่างน่ะครับ &lt;a href=&quot;http://dl-2.one2up.com/onetwo/content/2012/8/20/86d236294d7c1f49b17aa4505622c4d0.zip&quot; target=&quot;_blank&quot;&gt;download&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/2954879307862628814/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/2954879307862628814' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/2954879307862628814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/2954879307862628814'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/08/preloader.html' title='การทำหน้ารอระหว่างโหลดข้อมูล (preloader)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhirmiN9CetxlPjuACFJ4977omFR_JKfeHBWlCBWboGAD76ZZYM-Qr45XeLq3iE0gn7HIJbOb10pTRbF2QHftFPy6fnqCrWVgr3Y5S39kr68nrFhWJhds4wJ9mumnMLBGlNWUd8pilJPRRu/s72-c/preload1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-7805406081779528442</id><published>2012-08-17T14:26:00.000+07:00</published><updated>2012-08-17T14:26:17.563+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>php กับการ upload ไฟล์ โดยนำ ajax เข้ามาช่วย</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
เป็นการใช้&lt;b&gt;โค้ด php&lt;/b&gt; มาเขียนคำสั่งในการ upload ไฟล์ และใช้ ajax มาช่วยในการแสดงสถานะการ upload และการทำงานขณะ upload ไฟล์อยู่ และเมื่อ upload เสร็จก็จะมีข้อความเตือน เป็นการเพิ่มลูกเล่นให้กับเวปของเราได้ดีเลยครับ มาดูตัวอย่าง &lt;b&gt;code&lt;/b&gt; กันเลย&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;code ไฟล์ index.php&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;&lt;br /&gt;
&amp;lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;lt;title&amp;gt;Max&#39;s AJAX File Uploader&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;lt;link href=&quot;style/style.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
function startUpload(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; document.getElementById(&#39;f1_upload_process&#39;).style.visibility = &#39;visible&#39;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; document.getElementById(&#39;f1_upload_form&#39;).style.visibility = &#39;hidden&#39;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; return true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function stopUpload(success){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; var result = &#39;&#39;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if (success == 1){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;result = &#39;&amp;lt;span class=&quot;msg&quot;&amp;gt;The file was uploaded successfully!&amp;lt;\/span&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&#39;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;result = &#39;&amp;lt;span class=&quot;emsg&quot;&amp;gt;There was an error during file upload!&amp;lt;\/span&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&#39;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; document.getElementById(&#39;f1_upload_process&#39;).style.visibility = &#39;hidden&#39;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; document.getElementById(&#39;f1_upload_form&#39;).innerHTML = result + &#39;&amp;lt;label&amp;gt;File: &amp;lt;input name=&quot;myfile&quot; type=&quot;file&quot; size=&quot;30&quot; /&amp;gt;&amp;lt;\/label&amp;gt;&amp;lt;label&amp;gt;&amp;lt;input type=&quot;submit&quot; name=&quot;submitBtn&quot; class=&quot;sbtn&quot; value=&quot;Upload&quot; /&amp;gt;&amp;lt;\/label&amp;gt;&#39;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; document.getElementById(&#39;f1_upload_form&#39;).style.visibility = &#39;visible&#39;; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; return true; &amp;nbsp;&lt;br /&gt;
}&lt;br /&gt;
//--&amp;gt;&lt;br /&gt;
&amp;lt;/script&amp;gt; &amp;nbsp;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div id=&quot;container&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;div id=&quot;header&quot;&amp;gt;&amp;lt;div id=&quot;header_left&quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;div id=&quot;header_main&quot;&amp;gt;Max&#39;s AJAX File Uploader&amp;lt;/div&amp;gt;&amp;lt;div id=&quot;header_right&quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;div id=&quot;content&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;form action=&quot;upload.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; target=&quot;upload_target&quot; onsubmit=&quot;startUpload();&quot; &amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;p id=&quot;f1_upload_process&quot;&amp;gt;Loading...&amp;lt;br/&amp;gt;&amp;lt;img src=&quot;loader.gif&quot; /&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;p id=&quot;f1_upload_form&quot; align=&quot;center&quot;&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;label&amp;gt;File: &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;input name=&quot;myfile&quot; type=&quot;file&quot; size=&quot;30&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/label&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;label&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;input type=&quot;submit&quot; name=&quot;submitBtn&quot; class=&quot;sbtn&quot; value=&quot;Upload&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/label&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;iframe id=&quot;upload_target&quot; name=&quot;upload_target&quot; src=&quot;#&quot; style=&quot;width:0;height:0;border:0px solid #fff;&quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div id=&quot;footer&quot;&amp;gt;&amp;lt;a href=&quot;http://www.ajaxf1.com&quot; target=&quot;_blank&quot;&amp;gt;Powered by AJAX F1&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;lt;/body&amp;gt; &amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggplQWmEGuuK9c1WiQzhUPtkskLN2tkpTN3mRapfzynjTlPe8Cq5hq7Y7PVofv9tsCYjajbOcATqAafNJGJFvY0rTtwbEpLQOJGTBt2wPLDunC3jexaJ1WbW3k_RdVD2s08pdjX1PPT1i2/s1600/ajax1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;168&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggplQWmEGuuK9c1WiQzhUPtkskLN2tkpTN3mRapfzynjTlPe8Cq5hq7Y7PVofv9tsCYjajbOcATqAafNJGJFvY0rTtwbEpLQOJGTBt2wPLDunC3jexaJ1WbW3k_RdVD2s08pdjX1PPT1i2/s320/ajax1.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVQhCjJdnN0QtpmxW6hmTuw5qq0t1OF5LQG9Mf8qtau32xRzbhj0a9T_ItxQ0uIaz9NmpAir1107AU529od-4SiqOqGNAJBc6sznCbS3TDh0Tj9Tr5DOY1MkFY5aWMPAZ5au5zzzrITrnR/s1600/ajax2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;166&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVQhCjJdnN0QtpmxW6hmTuw5qq0t1OF5LQG9Mf8qtau32xRzbhj0a9T_ItxQ0uIaz9NmpAir1107AU529od-4SiqOqGNAJBc6sznCbS3TDh0Tj9Tr5DOY1MkFY5aWMPAZ5au5zzzrITrnR/s320/ajax2.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6bDg56wadbhjiPVDAl8YQfBQk0kpKApubs_U7foIWUxxLqh2gKf9k9nEmBRC0YQg02lqqXLZqMVd4kuFIMrTkmHFVfwNqhYo8XzWDuFvChWdzmugPJIDROmXp9qLmpmYQw5v7Bv66qmPN/s1600/ajax3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;168&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6bDg56wadbhjiPVDAl8YQfBQk0kpKApubs_U7foIWUxxLqh2gKf9k9nEmBRC0YQg02lqqXLZqMVd4kuFIMrTkmHFVfwNqhYo8XzWDuFvChWdzmugPJIDROmXp9qLmpmYQw5v7Bv66qmPN/s320/ajax3.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
ส่วนอันนี้เป็นไฟล์ประกอบน่ะครับ &lt;a href=&quot;http://dl-13.one2up.com/onetwo/content/2012/8/17/4beb383b997a5e64e67210ffcea95ab5.rar&quot; target=&quot;_blank&quot;&gt;download&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/7805406081779528442/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/7805406081779528442' title='2 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/7805406081779528442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/7805406081779528442'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/08/php-upload-ajax.html' title='php กับการ upload ไฟล์ โดยนำ ajax เข้ามาช่วย'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggplQWmEGuuK9c1WiQzhUPtkskLN2tkpTN3mRapfzynjTlPe8Cq5hq7Y7PVofv9tsCYjajbOcATqAafNJGJFvY0rTtwbEpLQOJGTBt2wPLDunC3jexaJ1WbW3k_RdVD2s08pdjX1PPT1i2/s72-c/ajax1.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-5425698607825967204</id><published>2012-08-17T10:40:00.000+07:00</published><updated>2012-08-17T13:07:47.290+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>โค้ดการจำกัดจำนวนอักษรที่จะกรอกใน textbox</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiv3sQb9wyeniKD-wytes321NZAh8o0Cc6RCEjY3nN-euE437f0iR6YjH9PxR_21iESSC4JZusauqIbSymyt6uXUuI9dPfZ0q3eNHfqiMYxg_WyTWLWOPn3a0e9kXPMbYCPBBa1pLEopsMH/s1600/field.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;156&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiv3sQb9wyeniKD-wytes321NZAh8o0Cc6RCEjY3nN-euE437f0iR6YjH9PxR_21iESSC4JZusauqIbSymyt6uXUuI9dPfZ0q3eNHfqiMYxg_WyTWLWOPn3a0e9kXPMbYCPBBa1pLEopsMH/s400/field.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;
เป็น&lt;b&gt;โค้ด javascript&lt;/b&gt; ที่ใช้ในการช่วยจำกัดจำนวนตัวอักษรที่จะกรอกใน textbox กล่าวคือถ้าหากกรอกข้อความใน textbox มากกว่าที่กำหนดไว้ก็จะเปลี่ยนสี background ใน textbox เพื่อเป็นการเตือน และถ้ายังกรอกเกินอีกก็จะไม่สามารถกรอกเพิ่มเติมได้ เรามาดูตัวอย่าง&lt;b&gt;โค้ด&lt;/b&gt;กันเลยครับ&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;
ตัวอย่าง &lt;b&gt;code&lt;/b&gt; หน้าหลัก&lt;/div&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;Bs_Misc.lib.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;Bs_LimitedTextarea.class.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;Bs_ColorUtil.lib.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;script&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;function init() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;myLimitedFoo = new Bs_LimitedTextarea(&#39;foo&#39;, 50);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;myLimitedFoo.setBgColorWarning();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;myLimitedFoo.draw();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;myLimitedBar = new Bs_LimitedTextarea(&#39;bar&#39;, 100);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;myLimitedBar.setBgColorWarning(60, &#39;char&#39;, &#39;FFC0C0&#39;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;myLimitedBar.draw();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;body onLoad=&quot;init();&quot;&amp;gt;&lt;br /&gt;
&amp;lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;10&quot; width=&quot;580&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;td valign=&quot;top&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;lt;b&amp;gt;Field 1&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;When 80% of the 50 chars are used, the background color starts to transform into red.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;lt;textarea name=&quot;foo&quot; id=&quot;foo&quot; cols=&quot;25&quot; rows=&quot;4&quot;&amp;gt;&amp;lt;/textarea&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;td valign=&quot;top&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;lt;b&amp;gt;Field 2&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;When 60 chars are used, the background color starts to transform into red.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;lt;textarea name=&quot;bar&quot; id=&quot;bar&quot; cols=&quot;25&quot; rows=&quot;4&quot; style=&quot;background-color:#C0FFFF;&quot;&amp;gt;this is a default value. this is a default value.&amp;lt;/textarea&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
ส่วนอันนี้เป็นไฟล์ประกอบน่ะครับ &lt;a href=&quot;http://dl-16.one2up.com/onetwo/content/2012/8/17/7d5175769338730888a5c5255922dbd0.rar&quot; target=&quot;_blank&quot;&gt;download&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;โค้ด&lt;/b&gt;อาจจะเยอะหน่อยน่ะครับ ลองนำไปประยุกต์ดูครับ</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/5425698607825967204/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/5425698607825967204' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/5425698607825967204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/5425698607825967204'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/08/textbox.html' title='โค้ดการจำกัดจำนวนอักษรที่จะกรอกใน textbox'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiv3sQb9wyeniKD-wytes321NZAh8o0Cc6RCEjY3nN-euE437f0iR6YjH9PxR_21iESSC4JZusauqIbSymyt6uXUuI9dPfZ0q3eNHfqiMYxg_WyTWLWOPn3a0e9kXPMbYCPBBa1pLEopsMH/s72-c/field.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-8632288375893861691</id><published>2012-08-16T16:16:00.000+07:00</published><updated>2012-08-16T16:18:46.221+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>โค้ด php กับ Banner Manager ระบบจัดการป้ายโฆษณา</title><content type='html'>ระบบจัดการป้ายโฆษณา สามารถจัดการป้ายโฆษณา และยังสามารถดูสถิติได้&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7XGmSnxGifphiiO6JjHAmnbw7J3RkA6rXuXNgWvESj_xtz_h7qxs0MyzjQWY3W05TyJZWwnZq1V03UaWQZsXXNPPjv_KbqbslPDGQQIHFHkKNCW6yvOXMGPw6xhE8OWQQvzlHQs4nkr1m/s1600/ad_banner1.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7XGmSnxGifphiiO6JjHAmnbw7J3RkA6rXuXNgWvESj_xtz_h7qxs0MyzjQWY3W05TyJZWwnZq1V03UaWQZsXXNPPjv_KbqbslPDGQQIHFHkKNCW6yvOXMGPw6xhE8OWQQvzlHQs4nkr1m/s1600/ad_banner1.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;u&gt;&lt;strong&gt;วิธีการติดตั้ง&lt;/strong&gt;&lt;/u&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
เมื่อ Downloads ได้แล้ว ให้ 
แตกไฟล์ Zip ใว้ใน Folder ทีก่ำหนดแต่ต้องอยู่ภายใน Path ของ Server 
เท่านั้น&amp;nbsp;ในที่นี้ผม แตกไฟล์ใว้ที่ 
C:\Appserv\www\ad_banner&amp;nbsp;การติดตั้งให้แก้ Config 
ที่ไฟล์ common/config.inc.php&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;config.inc.php&lt;/strong&gt;&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;span class=&quot;fontcode&quot;&gt;//(1) ตั้งค่าต่างๆ ของ MySQL 
Server&lt;br /&gt;$host = &quot;localhost&quot;;&lt;br /&gt;$user = &quot;&quot;;&lt;br /&gt;$passwd = &quot;&quot;;&lt;br /&gt;$dbname = 
&quot;ad_banner&quot;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;span class=&quot;fontcode&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;span class=&quot;fontcode&quot;&gt;จากนั้นให้ใช้ phpMyAdmin ทำการ dump ตารางจากไฟล์ db.sql&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;span class=&quot;fontcode&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrNWhWC84M7r8ursTUiBV-SeWprZ736E3Qw6ZG75hRd1-bE-YKf8_cgLWu6e8VJWsPGDjWdSHfYir0pElOdOMhpb35szIOo6xhKXB_hr9hWJHR-2h9rkxiLvT6tkMHXMQ3xjT7scHj9ZES/s1600/ad_banner2.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrNWhWC84M7r8ursTUiBV-SeWprZ736E3Qw6ZG75hRd1-bE-YKf8_cgLWu6e8VJWsPGDjWdSHfYir0pElOdOMhpb35szIOo6xhKXB_hr9hWJHR-2h9rkxiLvT6tkMHXMQ3xjT7scHj9ZES/s1600/ad_banner2.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMU5378hgBHe1h2ZhWEU5o6ylv61J03UHbB_3PBR112yAaHIvAsamOw-avOb8fLuPY3W68S33nxStXbbz6l6OPKSh9rSJ7JRv8YBVP3pPktEjOGKW24AYsTdc0Ug-99LDS86dpmgrnUn_u/s1600/ad_banner3.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMU5378hgBHe1h2ZhWEU5o6ylv61J03UHbB_3PBR112yAaHIvAsamOw-avOb8fLuPY3W68S33nxStXbbz6l6OPKSh9rSJ7JRv8YBVP3pPktEjOGKW24AYsTdc0Ug-99LDS86dpmgrnUn_u/s1600/ad_banner3.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
หลังจาก dump ตารางเสร็จเรียบร้อยแล้ว สามารถใช้งานได้เลย Run http://localhost/ad_banner/test.php&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh111bHro0MVqVcFjny5r4YC8eKbzil8Ku7ijDT12RspNLuGZtWpORVdAZIASABqnVaaT4chGKuKZIpa9f_rYYQEcm8a6Op8X4M6893AW3DFHnXF_W28LUKmYJZzEzpAYp6fklrhzizUCrM/s1600/ad_banner4.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh111bHro0MVqVcFjny5r4YC8eKbzil8Ku7ijDT12RspNLuGZtWpORVdAZIASABqnVaaT4chGKuKZIpa9f_rYYQEcm8a6Op8X4M6893AW3DFHnXF_W28LUKmYJZzEzpAYp6fklrhzizUCrM/s1600/ad_banner4.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
ระบบ 
Admin&lt;br /&gt;http://localhost/ad_banner/admin/index.php&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh90W95XEsf2NsgoE-uL-Em4G7xh8zWLx6Q08x9UfLQR3bNr3xctlZs1YzmwYdo3m7Tz5U7Vz5d_y0njETMf5Bh_sbayXhFmAaPEHBI5fXDb4aruSanxHcLIuCLVKqccX1jI5MWvlXDnRGw/s1600/ad_banner5.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh90W95XEsf2NsgoE-uL-Em4G7xh8zWLx6Q08x9UfLQR3bNr3xctlZs1YzmwYdo3m7Tz5U7Vz5d_y0njETMf5Bh_sbayXhFmAaPEHBI5fXDb4aruSanxHcLIuCLVKqccX1jI5MWvlXDnRGw/s1600/ad_banner5.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
User : admin&lt;br /&gt;Pass : admin&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgr4pQw2n5nT8pFBxO_eWPancImDewI8ug-om1vFDkE3AftHBP2GWRQxKdpQy74B1bxu9pfu2hLZcRqgBwyGJFyjFohxahRSzN3Imch8LjdmGYti-CLlaRXYmuxDHksRvVEKBkMo27hzZkV/s1600/ad_banner6.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgr4pQw2n5nT8pFBxO_eWPancImDewI8ug-om1vFDkE3AftHBP2GWRQxKdpQy74B1bxu9pfu2hLZcRqgBwyGJFyjFohxahRSzN3Imch8LjdmGYti-CLlaRXYmuxDHksRvVEKBkMo27hzZkV/s1600/ad_banner6.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span class=&quot;detailTutorial&quot;&gt;สามารถเข้าไปแก้ไขจัดการ Banner ต่าง ๆ ได้เลยครับ&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
ส่วนอันนี้เป็นไฟล์ประกอบครับ&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/8632288375893861691/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/8632288375893861691' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/8632288375893861691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/8632288375893861691'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/08/php-banner-manager.html' title='โค้ด php กับ Banner Manager ระบบจัดการป้ายโฆษณา'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7XGmSnxGifphiiO6JjHAmnbw7J3RkA6rXuXNgWvESj_xtz_h7qxs0MyzjQWY3W05TyJZWwnZq1V03UaWQZsXXNPPjv_KbqbslPDGQQIHFHkKNCW6yvOXMGPw6xhE8OWQQvzlHQs4nkr1m/s72-c/ad_banner1.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-7220862648473971165</id><published>2012-08-06T14:22:00.004+07:00</published><updated>2012-08-06T14:22:48.355+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>ตัวอย่างการซ่อนหรือแสดง textbox เมื่อเปลี่ยนเงื่อนไขใน listbox</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
ตัวอย่า&lt;b&gt;งโค้ด&lt;/b&gt;นี้จะเป็นการใช้ javascript ในการซ่อนหรือแสดง textbox เมื่อเปลี่ยนเงื่อนไขใน listbox ซึ่งจาก &lt;b&gt;code&lt;/b&gt; ตัวอย่างนี้เมื่อเปลี่ยนค่าใน listbox เป็น โสด ก็จะมี textbox ปรากฏขึ้นมาให้กรอก ชื่อ, นามสกุล และเลขประจำตัวประชาชน ขึ้นมา แต่ถ้าเปลี่ยนเป็นกรณีอื่น ๆ ก็จะไม่มี text box ปรากฏขึ้นมา ยังไงก็ลองนำไปประยุกต์ใช้ในการทำฟอร์มสำหรับกรอกข้อมูลได้น่ะครับ&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
ตัวอย่าง &lt;b&gt;code&lt;/b&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;function chksatatus(sx){&lt;br /&gt;if (sx==&quot;โสด&quot;){&lt;br /&gt;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;document.getElementById(&#39;det1&#39;).style.display=&#39;none&#39;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;document.getElementById(&#39;det2&#39;).style.display=&#39;none&#39;;&lt;br /&gt;}else{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;document.getElementById(&#39;det1&#39;).style.display=&#39;block&#39;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;document.getElementById(&#39;det2&#39;).style.display=&#39;block&#39;;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;select&amp;nbsp; onChange=&quot;chksatatus(this.value);&quot; 
name=&quot;citizen_satatus&quot;id=&quot;citizen_satatus&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;option 
value=&quot;โสด&quot;&amp;gt;โสด&amp;lt;/option&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;option&amp;nbsp; 
value=&quot;สมรส&quot;selected&amp;gt;สมรส&amp;lt;/option&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;option&amp;nbsp;&amp;nbsp; 
value=&quot;หย่า&quot;&amp;gt;หย่า&amp;lt;/option&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;option&amp;nbsp;&amp;nbsp; 
value=&quot;หม้าย&quot;&amp;gt;หม้าย&amp;lt;/option&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;lt;/select&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;table&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;lt;tr id=&#39;det1&#39;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;lt;td&amp;gt;&amp;lt;div align=&quot;right&quot;&amp;gt;ชื่อคู่สมรส 
:&amp;amp;nbsp;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;label&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;lt;input name=&quot;citizen_namesamee&quot; type=&quot;text&quot; id=&quot;citizen_namesamee&quot;&amp;nbsp; 
/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;div 
align=&quot;right&quot;&amp;gt;นามสกุล :&amp;amp;nbsp;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;lt;td&amp;gt;&amp;lt;label&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input name=&quot;citizen_surnamesamee&quot; 
type=&quot;text&quot; id=&quot;citizen_surnamesamee&quot;&amp;nbsp; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;lt;/label&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;tr id=&#39;det2&#39;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;lt;td&amp;gt;&amp;lt;div align=&quot;right&quot;&amp;gt;รหัสบัตรประจำตัวประชาชนคู่สมรส 
:&amp;amp;nbsp;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;label&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;lt;input name=&quot;citizen_sameeid&quot; type=&quot;text&quot; id=&quot;citizen_sameeid&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;lt;/label&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&amp;amp;nbsp;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;lt;td&amp;gt;&amp;amp;nbsp;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/table&amp;gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/7220862648473971165/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/7220862648473971165' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/7220862648473971165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/7220862648473971165'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/08/textbox-listbox.html' title='ตัวอย่างการซ่อนหรือแสดง textbox เมื่อเปลี่ยนเงื่อนไขใน listbox'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-1614989296685057320</id><published>2012-08-01T14:36:00.000+07:00</published><updated>2012-08-01T14:36:34.305+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>php กับการ upload ไฟล์แบบไม่เปลี่ยนหน้า</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;code php&lt;/b&gt; นี้เกี่ยวกับวิธีการทำ upload ไฟล์ ซึ่งหลายท่านอาจะเคยทำมาแล้วแต่ &lt;b&gt;code&lt;/b&gt; ตัวนี้มีความพิเศษกว่าวิธีที่ผมเคยใช้มาก่อน นั้นก็คือมันเป็น&lt;b&gt;โค้ด&lt;/b&gt;ที่ทำการ upload โดยที่ไม่มีการเปลี่ยนหน้าให้รำคาญใจเลยทุกอย่างทำเสร็จในหน้าเดียว แต่ดู&lt;b&gt;โค้ด&lt;/b&gt;แล้วอาจจะยุ่งยากนิดหน่อย แต่ก็ได้ผลลัพธ์ที่คุ้มค่าทีเดียวครับ ดูตัวอย่าง &lt;b&gt;code php&lt;/b&gt; ด้านล่างเลยครับ&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
ขั้นตอนแรกเขียน Form Upload และ Script Upload ก่อน&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;โค้ด&lt;/b&gt;ไฟล์ upload.html&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;meta http-equiv=&quot;Content-Type&quot; 
content=&quot;text/html; charset=windows-874&quot;&amp;gt;&lt;br /&gt;
&amp;lt;title&amp;gt;Upload 
ไม่เปลี่ยนหน้า&amp;lt;/title&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #009933;&quot;&gt;&amp;lt;script 
language=&quot;javascript&quot;&amp;gt;&lt;br /&gt;function clickupload()&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;if ( 
document.getElementById(&#39;fileupload&#39;).value.length == 0 )&lt;br /&gt;{&lt;br /&gt;alert( &#39;ระบุ 
File ที่จะ Upload &#39; ) ;&lt;br /&gt;return false ;&lt;br /&gt;}&lt;/span&gt;&lt;span style=&quot;color: #009933;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: red;&quot;&gt;document.getElementById(&#39;upmsg&#39;).innerHTML = &#39;กำลัง Upload 
อยู่ รอซักครู่...&#39; ;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #999999;&quot;&gt;document.getElementById(&#39;btnUpload&#39;).value = 
&quot;ส่งไปแล้วไม่ต้องคลิกซ้ำ&quot;;&lt;br /&gt;document.getElementById(&#39;btnUpload&#39;).disabled = 
true ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;return true ;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc9900;&quot;&gt;function 
uploadok(pathfile)&lt;br /&gt;{&lt;br /&gt;document.getElementById(&#39;fileupload&#39;).value 
=&quot;&quot;;&lt;br /&gt;document.getElementById(&#39;upmsg&#39;).innerHTML = &#39;Upload เสร็จแล้ว 
&amp;lt;br&amp;gt; file อยู่ที่&amp;lt;Br&amp;gt;&amp;lt;a href=&quot;&#39;+pathfile+&#39;&quot; 
target=&quot;_blank&quot;&amp;gt;&#39;+pathfile+&#39;&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;ระบุ File ใหม่ต่อไปได้เลย&#39; 
;&lt;br /&gt;document.getElementById(&#39;btnUpload&#39;).value = &quot;Upload 
เลย&quot;;&lt;br /&gt;document.getElementById(&#39;btnUpload&#39;).disabled = 
false;&lt;br /&gt;document.getElementById(&#39;frmUpload&#39;).reset() ;&lt;br /&gt;return true 
;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: #0099cc;&quot;&gt;&amp;lt;iframe id=&quot;uploadtarget&quot; name=&quot;uploadtarget&quot; src=&quot;&quot; 
style=&quot;width:0px;height:0px;border:0&quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;lt;form 
id=&quot;frmUpload&quot; action=&quot;upload.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; 
&lt;span style=&quot;color: #009933;&quot;&gt;onsubmit=&quot;return clickupload();&quot;&lt;/span&gt; &lt;span style=&quot;color: #0099cc;&quot;&gt;target=&quot;uploadtarget&quot;&lt;/span&gt;&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;span 
id=&quot;upmsg&quot;&amp;gt;ระบุ File ที่จะ Upload&amp;lt;/span&amp;gt;&lt;/span&gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;input id=&quot;fileupload&quot; 
name=&quot;fileupload&quot; type=&quot;file&quot;&amp;gt;&amp;amp;nbsp;&lt;br /&gt;
&amp;lt;input id=&quot;btnUpload&quot; 
type=&quot;submit&quot; value=&quot;&lt;span style=&quot;color: #999999;&quot;&gt;Upload 
เลย&lt;/span&gt;&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
คำอธิบาย&lt;b&gt;โค้ด&lt;/b&gt;สี&lt;span style=&quot;color: #009933;&quot;&gt;สีเขียว &lt;/span&gt;คือ&amp;nbsp;เมื่อกด Submit มันจะ Load หน้าใหม่ ฉะนั้นผมจึงเพิ่ม Target เข้าไปให้ 
ผลที่ได้ไปลงไว้ที่ Window ชื่อ uploadtarget&amp;nbsp;โดย Window ชื่อ uploadtarget 
นี้ผมกำหนดเป็นแบบ iframe ซะเลย แถมกำหนดให้แสดงผลแบบ 0 ด้วย และผมก็เพิ่ม&amp;nbsp;Javascript เพื่อตรวจสอบข้อมูลก่อนว่า คนกดต้องระบุ path File เข้ามา&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
คำอธิบาย&lt;b&gt;โค้ด&lt;/b&gt;สี&lt;span style=&quot;color: red;&quot;&gt;แดง &lt;/span&gt;คือ การบอกสถานะการดำเนินการ&amp;nbsp;คราวนี้เมื่อคลิก submit ระบบจะทำการเปลี่ยน ข้อความเป็น &lt;span style=&quot;color: red;&quot;&gt;&lt;strong&gt;กำลัง Upload 
&lt;/strong&gt;&lt;/span&gt;และทำการล๊อกปุ่มไม่ให้คลิกเข้ามาซ้ำอีก&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
และตามด้วยโค้ดไฟล์&amp;nbsp;upload.php&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;lt;?&lt;br /&gt;
&lt;span style=&quot;color: #00cccc;&quot;&gt;&lt;br /&gt;sleep(3);&lt;/span&gt;&lt;br /&gt;
$file = 
$_FILES[&#39;fileupload&#39;][&#39;name&#39;];&lt;br /&gt;
$typefile = $_FILES[&#39;fileupload&#39;][&#39;type&#39;]; 
&lt;br /&gt;
$sizefile = $_FILES[&#39;fileupload&#39;][&#39;size&#39;]; 
&lt;/div&gt;
$tempfile = date(&quot;Y-m-d&quot;).&quot;-&quot;.$file;&lt;br /&gt;
copy($_FILES[&#39;fileupload&#39;][&#39;tmp_name&#39;],$tempfile);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;script 
language=&quot;JavaScript&quot;&amp;gt;&lt;br /&gt;&amp;lt;!--&lt;br /&gt;window.parent.uploadok(&#39;&amp;lt;?=$tempfile?&amp;gt;&#39;);&lt;br /&gt;//--&amp;gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
พอ Script upload.php ทำงานก็จะส่งค่ากลับมาที่หน้าหลักและรายงานผลเรียบร้อยแล้ว&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/1614989296685057320/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/1614989296685057320' title='10 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/1614989296685057320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/1614989296685057320'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/08/php-upload.html' title='php กับการ upload ไฟล์แบบไม่เปลี่ยนหน้า'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-4265750523471161966</id><published>2012-07-30T16:14:00.000+07:00</published><updated>2012-07-30T16:14:04.101+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>PHP กับเทคนิคการแปลง IP ให้เป็น .xxx</title><content type='html'>&lt;b&gt;code php&lt;/b&gt; วันนี้ขอกล่าวถึงเรื่องของ IP ซึ่งเป็นการแปลงค่า IP ให้เป็น .xxx เพื่อป้องกันผู้ใช้งานเห็นค่า IP ที่แท้จริง อาจนำ&lt;b&gt;โค้ด php&lt;/b&gt; ตัวนี้ไปประยุกต์ใช้ในการทำระบบงาน การทำเว็บบอร์ด หรือการโพสข้อความ ก็ได้ เรามาดูตัวอย่าง &lt;b&gt;code php&lt;/b&gt; เลยดีกว่า จะมีด้วยกัน 3 วิธีน่ะครับ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;วีธีที่1&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;

&lt;div class=&quot;boxcode&quot;&gt;
&lt;div&gt;
$ip=&#39;192.168.10.100&#39;;&lt;/div&gt;
&lt;div&gt;
$new =preg_replace(&#39;/^((\d+\.){3})(.*)/&#39;,&#39;\\1xxx&#39;,$ip);&lt;/div&gt;
&lt;div&gt;
echo $new;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;strong&gt;วีธีที่2 &amp;nbsp;&lt;/strong&gt;&lt;br /&gt;

&lt;div class=&quot;boxcode&quot;&gt;
&lt;div&gt;
$ip=&#39;192.168.20.200&#39;;&lt;/div&gt;
&lt;div&gt;
$show=explode(&quot;.&quot;,$ip);&lt;/div&gt;
&lt;div&gt;
echo $show[&#39;0&#39;],&quot;.&quot;,$show[&#39;1&#39;],&quot;.&quot;,$show[&#39;2&#39;],&quot;.xxx&quot;;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;strong&gt;วีธีที่3&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;

&lt;div class=&quot;boxcode&quot;&gt;
&lt;div&gt;
$ip=&#39;192.16.30.253&#39;;&lt;/div&gt;
&lt;div&gt;
echo substr($ip,0,strrpos($ip,&quot;.&quot;)).&quot;.xxx&quot;;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/4265750523471161966/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/4265750523471161966' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/4265750523471161966'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/4265750523471161966'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/07/php-ip-xxx.html' title='PHP กับเทคนิคการแปลง IP ให้เป็น .xxx'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-8376105063815396356</id><published>2012-07-26T16:12:00.000+07:00</published><updated>2012-07-27T09:35:45.301+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>PHP กับการป้องกันการลงทะเบียนอัตโนมัติด้วย CAPTCHA</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;บทความ php&lt;/b&gt; วันนี้ขอนำเสอนเจ้าต้ว CAPTCHA มันช่วยให้การใช้เน็ตของคุณปลอดภัยด้วยวัตถุประสงค์สำคัญของมันก็เพื่อความปลอดภัยโดยเฉพาะเว็บไซต์ที่  ต้องมีการป้อนข้อมูลส่วนตัว &amp;nbsp;เช่นการลงทะเบียนผู้ใช้งาน, การโพสข้อมูลใน webboard ฯลฯ เนื่องจากพวกแฮกเกอร์ส่วนใหญ่จะใช้สิ่งที่เรียกว่า bots ในการโจมตีผู้ใช้ ซึ่ง bots ที่ว่านี้สามารถสร้างขึ้นโดยคอมพิวเตอร์  แต่เนื่องจากคอมพิวเตอร์ไม่สามารถแก้ปัญหาการทดสอบด้วย CAPTCHA ได้  จะต้องอาศัยมนุษย์ที่เพ่งดูกราฟฟิกยุ่งเหยิงเหล่านี้  และแกะตัวอักษรออกมาเพื่อพิมพ์ยืนยันอีกที  ทำให้ผู้ใช้ปลอดภัยจาก bots เหล่านี้ไปโดยปริยาย&amp;nbsp;&lt;span style=&quot;background-color: white;&quot;&gt;ซึ่งวิธีการสร้างและใช้งาน CAPTCHA ผมขอยกตัวอย่าง&lt;b&gt;โค้ด php&lt;/b&gt; ให้เอาไปประยุกต์ใช้กันนะครับ&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ขั้นตอนแรก&lt;/span&gt;ให้สร้างไฟล์  &lt;b&gt;captcha.php&lt;/b&gt; ภายในไฟล์เขียน&lt;b&gt;โค้ด php&lt;/b&gt; ดังนี้&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;pre style=&quot;display: inline;&quot;&gt;&amp;lt;?&lt;span style=&quot;font-family: inherit;&quot;&gt;php
session_start();
  
 class CaptchaSecurityImages {
  
    var $font = &#39;font.ttf&#39;;  // เปลี่ยน font ได้ตามต้องการ
  
    function generat&lt;/span&gt;eCode($characters) {
    $possible = &#39;abcdefghjkmnpqrstvwxyz&#39;;  // ตัวอักษรที่ต้องการจะเอาสุ่มเป็น Captcha
    $code = &#39;&#39;;
    $i = 0;
    while ($i &amp;lt; $characters) { 
    $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
    $i++;
    }
    return $code;
    }
  
    function CaptchaSecurityImages($width=&#39;120&#39;,$height=&#39;40&#39;,$characters=&#39;6&#39;) {
    $code = $this-&amp;gt;generateCode($characters);
    $font_size = $height * 0.9;  // font size ที่จะโชว์ใน Captcha
    $image = imagecreate($width, $height) or die(&#39;Cannot initialize new GD image stream&#39;);
    $background_color = imagecolorallocate($image, 255, 255, 255);  // กำหนดสีในส่วนต่่างๆ
    $text_color = imagecolorallocate($image, 141, 192, 42);
    $noise_color = imagecolorallocate($image, 172, 208, 95);
    for( $i=0; $i&amp;lt;($width*$height)/5; $i++ ) { // สุ่มจุดภาพพื้นหลัง
    imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
    }
    for( $i=0; $i&amp;lt;($width*$height)/200; $i++ ) { // สุ่มเส้นภาพพื้นหลัง
    imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
    }
    /* สร้าง Text box และเพิ่ม Text */
    $textbox = imagettfbbox($font_size, 0, $this-&amp;gt;font, $code) or die(&#39;Error in imagettfbbox function&#39;);
    $x = ($width - $textbox[4])/2;
    $y = ($height - $textbox[5])/2;
    imagettftext($image, $font_size, 0, $x, $y, $text_color, $this-&amp;gt;font , $code) or die(&#39;Error in imagettftext function&#39;);
    /* display captcha image ไปที่ browser */
    header(&#39;Content-Type: image/jpeg&#39;);
    imagejpeg($image);
    imagedestroy($image);
    $_SESSION[&#39;security_code&#39;] = $code;
    }
  
 }
  
 $width = isset($_GET[&#39;width&#39;]) &amp;amp;&amp;amp; $_GET[&#39;height&#39;] &amp;lt; 600 ? $_GET[&#39;width&#39;] : &#39;120&#39;;
 $height = isset($_GET[&#39;height&#39;]) &amp;amp;&amp;amp; $_GET[&#39;height&#39;] &amp;lt; 200 ? $_GET[&#39;height&#39;] : &#39;40&#39;;
 $characters = isset($_GET[&#39;characters&#39;]) &amp;amp;&amp;amp; $_GET[&#39;characters&#39;] &amp;gt; 2 ? $_GET[&#39;characters&#39;] : &#39;6&#39;;
  
 $captcha = new CaptchaSecurityImages($width,$height,$characters);&amp;nbsp;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;pre style=&quot;display: inline;&quot;&gt;?&amp;gt;&lt;/pre&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre style=&quot;display: inline;&quot;&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;display: inline;&quot;&gt;&lt;div&gt;
&lt;u&gt;ขั้นตอนที่สอง&lt;/u&gt; สร้างไฟล์ &lt;b&gt;getdata.php&lt;/b&gt; ใว้ใน Folder เดียวกันกับ &lt;b&gt;captcha.php&lt;/b&gt; โดยภายใน &lt;b&gt;code php&lt;/b&gt; เขียนดังนี้&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;display: inline;&quot;&gt;&amp;lt;?php
session_start();
if($_REQUEST[&#39;task&#39;]==&#39;add&#39;){ //หากมีการ Submit ข้อมูลผ่าน From มา
 if($_SESSION[&#39;security_code&#39;]!=$_POST[&#39;secret_code&#39;]) { // Check 
  echo &quot;&amp;lt;p&amp;gt;คุณใส่รหัสตัวอักษรไม่ถูกต้องกรุณากรอกใหม่&amp;lt;/p&amp;gt;&quot;;
 }else{
  echo &quot;&amp;lt;p&amp;gt;รหัสถูกต้อง (สามารถใส่โค๊ดบันทีก หรือโค๊ดอะไรก็ได้ที่ต้องการ)&amp;lt;/p&amp;gt;&quot;;
 }
}
?&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;
&amp;lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&amp;gt;
&amp;lt;title&amp;gt;Untitled Document&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
&amp;lt;form method=&quot;post&quot; action=&quot;?task=add&quot;&amp;gt;
&amp;lt;input name=&quot;name&quot; type=&quot;text&quot; /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;
&amp;lt;input name=&quot;detail&quot; type=&quot;text&quot; /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;
&amp;lt;iframe name=&quot;a&quot;src=&quot;captcha.php?width=100&amp;amp;height=40&amp;amp;characters=5&quot; alt=&quot;captcha&quot; frameborder=&quot;0&quot; width=&quot;120&quot; height=&quot;60&quot; scrolling=&quot;no&quot;&amp;gt;&amp;lt;/iframe&amp;gt;
&amp;lt;a href=&quot;captcha.php?width=100&amp;amp;height=40&amp;amp;characters=5&quot; target=&quot;a&quot;&amp;gt;&amp;lt;img src=&quot;refresh.gif&quot; width=&quot;13&quot; height=&quot;13&quot;  border=&quot;0&quot; /&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;
&amp;lt;br /&amp;gt;
พิมพ์อักขระ ตามที่คุณเห็นในภาพ  วิธีการนี้จะช่วยป้องกันการลงทะเบียนโดยอัตโนมัติ&amp;lt;br /&amp;gt;
&amp;lt;input name=&quot;secret_code&quot; type=&quot;text&quot; /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;
&amp;lt;input  type=&quot;submit&quot; value=&quot;submit&quot; /&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;display: inline;&quot;&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
ต่อมาก็ดาวน์โหลด font.ttf และ refresh.gif ตามไฟล์ลิ้งค์ครับ http://bc46.com/forum/index.php?action=dlattach;topic=67.0;attach=77 เอาไปใว้ใน Folder เดียวกับไฟล์ &lt;b&gt;getdata.php&lt;/b&gt; ,&lt;b&gt;captcha.php&lt;/b&gt; เสร็จแล้วก็ลองรันไฟล์ &lt;b&gt;getdata.php&lt;/b&gt;   ทดสอบดูเลยครับ นี่เป็นเพียงตัวอย่างเฉยๆ ลองนำไปประยุกต์ใช้ดูครับ&lt;/div&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/8376105063815396356/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/8376105063815396356' title='3 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/8376105063815396356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/8376105063815396356'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/07/php-captcha.html' title='PHP กับการป้องกันการลงทะเบียนอัตโนมัติด้วย CAPTCHA'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-6030083298342182829</id><published>2012-07-24T15:07:00.001+07:00</published><updated>2012-07-24T15:07:25.320+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>PHP กับการทำ form login แบบป้องกันการไม่ได้ login</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;จาก&lt;/span&gt;&lt;b&gt;บทความ php&lt;/b&gt;&lt;span style=&quot;background-color: white;&quot;&gt; เรื่อง&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;
&lt;/span&gt;&lt;a href=&quot;http://hotcodephp.blogspot.com/2012/07/php-form-login.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;PHP&lt;/b&gt; กับการทำ form login อย่างง่าย&lt;/a&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;จะเป็นการ login ที่มีรูปแบบธรรมดา แต่ก็มีปัญหาว่าหากผู้ใช้งานเข้าหน้าหลักของระบบโดยที่ไม่ได้ผ่านการ login ได้หรือไม่ ก็ต้องบอกว่ามีความเป็นไปได้ แล้วเราจะทำหน้า login ไว้ป้องกันทำไม ดังนั้นวันนี้เรามาดูวิธีแก้ไขกันดีกว่า ลักษณะ&lt;/span&gt;&lt;b&gt;โค้ด php&lt;/b&gt;&lt;span style=&quot;background-color: white;&quot;&gt; มันก็จะคล้าย ๆ กับ &lt;/span&gt;&lt;b&gt;บทความ&lt;/b&gt;&lt;span style=&quot;background-color: white;&quot;&gt;
&lt;/span&gt;&lt;a href=&quot;http://hotcodephp.blogspot.com/2012/07/php-form-login.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;PHP&lt;/b&gt;&amp;nbsp;กับการทำ form login อย่างง่าย&lt;/a&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;แต่จะมีการใช้คำสั่งที่เกี่ยวกับ session เข้ามาเกี่ยวข้อง มาดูตัวอย่าง&lt;b&gt;โค้ด&lt;/b&gt;กันเลยครับ&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;b&gt;1. โค้ด login.php&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;div&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: red;&quot;&gt;ob_start();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: red;&quot;&gt;session_start();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: red;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;check.php&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;table width=&quot;300&quot; height=&quot;27&quot; border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;10&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;tr&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;lt;td&amp;gt;รหัสผู้ใช้งาน&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;td&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;div align=&quot;center&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;input type=&quot;text&quot; name=&quot;user&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;tr&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;lt;td&amp;gt;รหัสผ่าน&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;td&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;div align=&quot;center&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;input type=&quot;password&quot; name=&quot;pass&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;tr&amp;gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;lt;td colspan=&quot;2&quot;&amp;gt;&amp;lt;p align=&quot;center&quot;&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;ตกลง&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;input type=&quot;reset&quot; name=&quot;Submit2&quot; value=&quot;ยกเลิก&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;/p&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/table&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/form&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
จากด้านบนตัวสีแดงเป็นการเปิดคำสั่ง session ให้เริ่มทำงาน ส่วน&lt;b&gt;โค้ด&lt;/b&gt;อื่น ๆ ก็เป็น&lt;b&gt;โค้ด&lt;/b&gt; form สำหรับ login ธรรมดา ๆ&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;2. สร้างฐานข้อมูลเพื่อจัดเก็บข้อมูลรหัสผู้ใช้งาน และรหัสผ่าน&lt;/b&gt; ซึ่งในที่นี้ผมใช้ MS Access ในการจัดเก็บ&lt;/div&gt;
&lt;div&gt;
3. &lt;b&gt;สร้าง code php เพื่อใช้ในการตรวจสอบว่าข้อมูลรหัสผู้ใช้งาน และรหัสผ่าน&lt;/b&gt;ที่ผู้ใช้งานกรอกมาตรงกับฐานข้อมูลที่มีอยู่หรือไม่ ดูตัวอย่าง &lt;b&gt;code&lt;/b&gt; check.php ด้านล่างเลยครับ&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;?php&lt;/div&gt;
&lt;div&gt;
ob_start();&lt;/div&gt;
&lt;div&gt;
session_start();&lt;/div&gt;
&lt;div&gt;
$dsn = &quot;login&quot;;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; // กำหนดชื่อ DSN&lt;/div&gt;
&lt;div&gt;
$user_name =&quot;&quot;;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// กำหนดชื่อล็อกอิน&lt;/div&gt;
&lt;div&gt;
$pass_word =&quot;&quot;;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// กำหนดรหัสผ่าน&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
$connect = odbc_connect($dsn, $user_name, $pass_word) or die(&quot;ติดต่อ DSN ไม่ได้&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
$sql = &quot;SELECT user.team, *&lt;/div&gt;
&lt;div&gt;
FROM [user]&lt;/div&gt;
&lt;div&gt;
WHERE (((user.username)=&#39;$user&#39;) AND ((user.password)=&#39;$pass&#39;))&quot;;&lt;/div&gt;
&lt;div&gt;
$exec = odbc_exec($connect, $sql);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// เริ่มเอ็กซิคิวต์คำสั่ง SQL&lt;/div&gt;
&lt;div&gt;
$num_rows = odbc_result($exec, 1);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; // ตัวแปรจำนวนเรกคอร์ด&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
if(empty($num_rows))&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
echo&quot;&amp;lt;br&amp;gt;&amp;lt;center&amp;gt;user หรือ password ไม่ถูกต้อง&amp;lt;/center&amp;gt;&amp;lt;/br&amp;gt;&quot;;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
else&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
session_start();&lt;/div&gt;
&lt;div&gt;
$_SESSION[id]=session_id();&lt;/div&gt;
&lt;div&gt;
$_SESSION[username]=$user;&lt;/div&gt;
&lt;div&gt;
header(&#39;location:main1.php&#39;);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
odbc_close($connect);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// ปิดการเชื่อมต่อ&lt;/div&gt;
&lt;div&gt;
?&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
จาก &lt;b&gt;code&lt;/b&gt;&amp;nbsp;จะมีลักษณะการทำงานคือ เมื่อตรวจสอบข้อมูลกับฐานข้อมูลแล้ว หากไม่มีผู้ใช้งานนี้ในฐานข้อมูลก็จะมีข้อความเตือนขึ้นมา แต่ถ้ามีข้อมูลในฐานข้อมูลก็จะเรียกใช้งาน session เพื่อเก็บข้อมูล sess_id และ username ไว้ในเครื่องเพื่อนำมาเรียกใช้งานครั้งต่อไป และเมื่อเก็บแล้วก็ให้ไปที่หน้าหลักของระบบต่อไป&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;4. การป้องกันการเข้าหน้าหลักโดยไม่ได้ผ่านการ login&lt;/b&gt;&amp;nbsp;ซึ่งจำเป็นที่จะต้องใส่ &lt;b&gt;code php&lt;/b&gt; นี้ในทุกหน้าที่เรามี หากไม่ได้ login เมื่อเข้ามาก็จะกลับไปหน้า login อีกครั้ง ตัวอย่างด้านล่างครับ&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;div&gt;
&amp;lt;?&lt;/div&gt;
&lt;div&gt;
session_start();&lt;/div&gt;
&lt;div&gt;
$sess_id=$_SESSION[id];&lt;/div&gt;
&lt;div&gt;
$sess_username=$_SESSION[username];&lt;/div&gt;
&lt;div&gt;
if ($sess_id&amp;lt;&amp;gt;session_id() or $sess_username==&quot;&quot;)&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
echo &quot;กรุณา Login &quot;;&lt;/div&gt;
&lt;div&gt;
echo &quot;&amp;lt;meta http-equiv=\&quot;refresh\&quot; content=\&quot;3;URL=login.php\&quot; target=mainFrame\&quot;&amp;gt;&quot;;&lt;/div&gt;
&lt;div&gt;
exit();&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
?&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
5. หลังจากการใช้งานระบบทุกครั้งจะต้อง logout ออกทุกครั้ง เพื่อเป็นการล้าง session ออกจากความจำของเครื่องเพื่อป้องกันคนอื่นมาใช้งานเครื่องเราต่อ ตัวอย่าง&lt;b&gt;โค้ด &lt;/b&gt;logout.php&lt;b&gt;&amp;nbsp;&lt;/b&gt;ด้านล่างเลยครับ&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;?php&lt;/div&gt;
&lt;div&gt;
session_start();&lt;/div&gt;
&lt;div&gt;
session_destroy();&lt;/div&gt;
&lt;div&gt;
header(&quot;Location: login.php&quot;);&lt;/div&gt;
&lt;div&gt;
?&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
ลองนำไปประยุกต์ใช้กันน่ะครับ&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/6030083298342182829/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/6030083298342182829' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/6030083298342182829'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/6030083298342182829'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/07/php-form-login-login.html' title='PHP กับการทำ form login แบบป้องกันการไม่ได้ login'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-162867976715041804</id><published>2012-07-23T15:49:00.000+07:00</published><updated>2012-07-23T16:13:35.306+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>PHP กับการทำ form login อย่างง่าย</title><content type='html'>&lt;b&gt;บทความ&lt;/b&gt;นี้จะขออธิบายเรื่องของการทำระบบ login โดยใช้&lt;b&gt;ภาษา php&lt;/b&gt; ในการเขียน&lt;b&gt;โค้ด php&lt;/b&gt;&amp;nbsp;ซึ่งการทำระบบ login ส่วนใหญ่จะใช้ในกรณีที่เราทำระบบขึ้นมาระบบหนึ่งแล้วต้องการให้ผู้ใช้งาน login เข้าระบบทุกครั้งที่เข้าใช้งาน เพื่อป้องกันข้อมูล หรือแสดงตัวตนของผู้ใช้งานก่อน สำหรับหลักการก็ง่าย ๆ ครับ คือ&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;b&gt;1. ทำ form login ขึ้นมา form หนึ่ง เพื่อให้ผู้ใช้งานกรอกข้อมูล&amp;nbsp;&lt;/b&gt;หน้าตาก็จะง่าย ๆ ละกันส่วนโค้ดก็ด้านล่างเลย&lt;br /&gt;
&lt;form action=&quot;check.php&quot; method=&quot;post&quot; name=&quot;form1&quot;&gt;
ตัวอย่าง &lt;b&gt;code&lt;/b&gt; ชื่อไฟล์ login.php&lt;br /&gt;
&lt;br /&gt;
&amp;lt;form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;bcheck.php&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;table width=&quot;300&quot; height=&quot;27&quot; border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;10&quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;รหัสผู้ใช้งาน&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;div align=&quot;center&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;input type=&quot;text&quot; name=&quot;user&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;รหัสผ่าน&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;div align=&quot;center&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;input type=&quot;password&quot; name=&quot;pass&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td colspan=&quot;2&quot;&amp;gt;&amp;lt;p align=&quot;center&quot;&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;ตกลง&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;lt;input type=&quot;reset&quot; name=&quot;Submit2&quot; value=&quot;ยกเลิก&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2. ให้จัดทำฐานข้อมูลเพื่อจัดเก็บรหัสผู้ใช้งาน และรหัสผ่าน ในบทความนี้ผมใช้ MS Access เป็นฐานข้อมูลน่ะครับ&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3. &lt;b&gt;สร้างโค้ดเพื่อตรวจสอบข้อมูลจากฐานข้อมูล&lt;/b&gt; ซึ่งผมใช้&lt;b&gt;โค้ด php&lt;/b&gt; ในการตรวจสอบ วิธีตรวจสอบก็คือ เมื่อผู้ใช้งานกรอกรหัสผู้ใช้งาน และรหัสผ่าน พอกดตกลงแล้วให้ไปที่หน้า &lt;b&gt;check.php&lt;/b&gt; เพื่อตรวจสอบว่ามีข้อมูลในฐานเราหรือเปล่าถ้าไม่มีก็ให้มีข้อความเตือนขึ้นมา แต่ถ้ามีก็ให้ไปหน้าหลักของระบบ ตัวอย่าง&lt;b&gt;โค้ด&lt;/b&gt;ก็ด้านล่างครับ&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$dsn = &quot;login&quot;;// กำหนดชื่อ DSN&lt;br /&gt;
$user_name =&quot;&quot;;// กำหนดชื่อล็อกอิน&lt;br /&gt;
$pass_word =&quot;&quot;;// กำหนดรหัสผ่าน&lt;br /&gt;
$connect = odbc_connect($dsn, $user_name, $pass_word) or die(&quot;ติดต่อ DSN ไม่ได้&quot;);&lt;br /&gt;
$sql = &quot;SELECT * FROM user where username = &#39;$user&#39; and &amp;nbsp;password = &#39;$pass&#39; &quot;;&lt;br /&gt;
$exec = odbc_exec($connect, $sql);// เริ่มเอ็กซิคิวต์คำสั่ง SQL&lt;br /&gt;
$Num_fields = odbc_num_fields($exec);// ตัวแปรจำนวนฟิลด์&lt;br /&gt;
$sql_count = &quot;SELECT Count(user.username) AS CountOfusername&lt;br /&gt;
FROM [user]&lt;br /&gt;
WHERE (((user.username)=&#39;$user&#39;) AND ((user.password)=&#39;$pass&#39;))&quot;;&lt;br /&gt;
$exec_count = odbc_exec($connect, $sql_count);// เริ่มเอ็กซิคิวต์คำสั่ง SQL&lt;br /&gt;
$num_rows = odbc_result($exec_count, 1);// ตัวแปรจำนวนเรกคอร์ด&lt;br /&gt;
if(empty($num_rows))&lt;br /&gt;
{&lt;br /&gt;
echo&quot;&amp;lt;br&amp;gt;&amp;lt;center&amp;gt;user หรือ password ไม่ถูกต้อง&amp;lt;/center&amp;gt;&amp;lt;/br&amp;gt;&quot;;&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
echo &quot;&amp;lt;meta http-equiv=\&quot;refresh\&quot; content=\&quot;3;URL=check.php\&quot; target=_self\&quot;&amp;gt;&quot;;&lt;br /&gt;
}&lt;br /&gt;
odbc_close($connect);// ปิดการเชื่อมต่อ&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ลองนำไปใช้ดูน่ะครับมีปัญหาก็ถามได้ครับ ไว้คราวหน้าผมจะเอา&lt;b&gt;โค้ด php&lt;/b&gt; ในการ login อีกแบบหนึ่งมาให้ดูซึ่งจะซับซ้อนกว่าและมีการป้องกันความปลอดภัยกว่าที่ดีกว่า&lt;/form&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/162867976715041804/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/162867976715041804' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/162867976715041804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/162867976715041804'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/07/php-form-login.html' title='PHP กับการทำ form login อย่างง่าย'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-1160236445235828279</id><published>2012-07-20T10:00:00.001+07:00</published><updated>2012-07-20T10:00:36.548+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>การทำ form ให้เลือกที่ radio buttom ก่อนถึงจะใส่ข้อมูลใน text field ได้</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
ใครเคยเขียน&lt;b&gt;โค้ด php&amp;nbsp;&lt;/b&gt;ทำ form ที่ให้ผู้ใช้งานบันทึกข้อมูลแล้วมีให้เลือกตรง radio buttom ไหมครับ แล้วเคยเจอปัญหาไหมว่าบางครั้งเราทำทั้ง radio buttom และ text field ในตัวเลือกเดียวกัน แต่ผู้ใช้งานบางคนเลือกแค่ radio buttom แต่ไม่ใส่ข้อมูลใน text field บางคนใส่ข้อมูลใน text field แต่ไม่เลือก radio buttom แล้วเราจะมีวิธีเขียน &lt;b&gt;code&lt;/b&gt; ป้องกันยังไง ลองอ่าน&lt;b&gt;บทความ&lt;/b&gt;นี้ดูครับ ก่อนอื่นดูรูปด้านล่างครับเพื่อจะได้ไม่งงกัน&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdhh-I0GPC6TIKmwXAdqPgogZ0UWgKfIs_2jrmJsoEmDOhkTHVRSVHgS1jEBQd2fF4IYPAUI-1oBFmg6hH4g4-_U17sXyAf2ogxfFCwsFc2bcH_nwFtN1AuSXw-Z4nWtyU_xSH_RX4n4B4/s1600/Untitled.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;146&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdhh-I0GPC6TIKmwXAdqPgogZ0UWgKfIs_2jrmJsoEmDOhkTHVRSVHgS1jEBQd2fF4IYPAUI-1oBFmg6hH4g4-_U17sXyAf2ogxfFCwsFc2bcH_nwFtN1AuSXw-Z4nWtyU_xSH_RX4n4B4/s400/Untitled.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
คราวนี้มาดู&lt;b&gt;โค้ด&lt;/b&gt;ตัวอย่างกันครับ&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;body&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;form id=&quot;form&quot; name=&quot;form&quot; method=&quot;post&quot; action=&quot;add1.php&quot; &amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;table width=&quot;100%&quot; border=&quot;2&quot; cellpadding=&quot;10&quot; cellspacing=&quot;0&quot; bordercolor=&quot;#000099&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;การดำเนินการ&amp;lt;/strong&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;input name=&quot;case1&quot; type=&quot;radio&quot; id=&quot;rdo2&quot; &lt;span style=&quot;color: red;&quot;&gt;onclick=&quot;document.form.case11.disabled=true;&quot;&lt;/span&gt; value=&quot;กรณีที่ 1&quot; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; กรณีที่ 1&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;br /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;input name=&quot;case1&quot; type=&quot;radio&quot; id=&quot;rdo3&quot; &lt;span style=&quot;color: red;&quot;&gt;onclick=&quot;document.form.case11.disabled=true;&quot;&lt;/span&gt; value=&quot;กรณีที่ 2&quot; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; กรณีที่ 2&amp;lt;br /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;input name=&quot;case1&quot; type=&quot;radio&quot; id=&quot;rdo4&quot; &lt;span style=&quot;color: red;&quot;&gt;onclick=&quot;document.form.case11.disabled=true;&quot;&lt;/span&gt; value=&quot;กรณีที่ 3&quot; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; กรณีที่ 3&amp;lt;br /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;input name=&quot;case1&quot; type=&quot;radio&quot; id=&quot;rdo5&quot; &lt;span style=&quot;color: red;&quot;&gt;onclick=&quot;document.form.case11.disabled=false;&quot;&lt;/span&gt; value=&quot;อื่นๆ&quot; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; อื่น ๆ โปรดระบุ&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;input &amp;nbsp;type=&quot;text&quot; id=&quot;case11&quot; size=&quot;60&quot; &amp;nbsp;name=&quot;case11&quot; &lt;span style=&quot;color: red;&quot;&gt;disabled&lt;/span&gt; /&amp;gt;&amp;lt;/td&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/tr&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/table&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;br /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;p align=&quot;center&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;บันทึก&quot; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;input type=&quot;reset&quot; name=&quot;Submit2&quot; value=&quot;ยกเลิก&quot; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/p&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/form&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/body&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
จาก&lt;b&gt;โค้ด&lt;/b&gt;ตัวคำสั่งหลักที่สำคัญก็คือตัวหนังสือสีแดงที่ใช้ onclick เข้ามาช่วย หลักการง่าย ๆ คือถ้าเราเลือกที่ช่อง &lt;span style=&quot;color: red;&quot;&gt;กรณี 1 - กรณี 3&lt;/span&gt; ช่อง &lt;span style=&quot;color: red;&quot;&gt;อื่น ๆ โปรดระบุ&lt;/span&gt; ก็จะเป็น &lt;span style=&quot;color: red;&quot;&gt;disabled&lt;/span&gt; แต่ถ้าเลือกที่ช่อง &lt;span style=&quot;color: red;&quot;&gt;อื่นๆ&lt;/span&gt; ช่อง&lt;span style=&quot;color: red;&quot;&gt; อื่น ๆ โปรดระบุ&lt;/span&gt; ก็จะเป็น &lt;span style=&quot;color: red;&quot;&gt;abled &lt;/span&gt;ลองนำไปประยุกต์ใช้ดูน่ะครับ หวังว่า&lt;b&gt;โค้ด&lt;/b&gt;ตัวนี้คงเป็นประโยชน์กับทุกคน&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/1160236445235828279/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/1160236445235828279' title='1 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/1160236445235828279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/1160236445235828279'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/07/form-radio-buttom-text-field.html' title='การทำ form ให้เลือกที่ radio buttom ก่อนถึงจะใส่ข้อมูลใน text field ได้'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdhh-I0GPC6TIKmwXAdqPgogZ0UWgKfIs_2jrmJsoEmDOhkTHVRSVHgS1jEBQd2fF4IYPAUI-1oBFmg6hH4g4-_U17sXyAf2ogxfFCwsFc2bcH_nwFtN1AuSXw-Z4nWtyU_xSH_RX4n4B4/s72-c/Untitled.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-5960353769593053013</id><published>2012-07-19T10:40:00.000+07:00</published><updated>2012-07-19T10:40:18.035+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>การทำ jump menu เพื่อเปิดหน้าต่างใหม่</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;บทความ php&lt;/b&gt;&amp;nbsp;นี้ขอพูดถึง jump menu ซึ่งเชื่อว่าหลายคนเคยใช้มากันบ้านแล้ว แต่เคยสงสัยหรือมีปัญหากันบ้างไหมว่าทำไมพอเวลาเลือกรายการใน jump menu เพื่อเปิดหน้าต่างใหม่นั้น มันจะเปิดแบบ target เป็นแบบ _blank ซึ่งบางครั้งมันจะไม่ค่อยสะดวกต่อการใช้งาน มันจะเปิดแบบ target เป็นแบบ _self ได้ไหม ก็ต้องได้สิครับเรามาดู&lt;b&gt;โค้ด&lt;/b&gt;ปกติก่อนนะครับ ผมขอเป็นแบบ&lt;b&gt;โค้ด php&lt;/b&gt;&amp;nbsp;น่ะ&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-874&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;title&amp;gt;Untitled Document&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;script type=&quot;text/JavaScript&quot;&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
function MM_jumpMenu(targ,selObj,restore){ //v3.0&lt;/div&gt;
&amp;nbsp; eval(targ+&quot;.location=&#39;&quot;+selObj.options[selObj.selectedIndex].value+&quot;&#39;&quot;);&lt;br /&gt;
&amp;nbsp; if (restore) selObj.selectedIndex=0;&lt;br /&gt;
}&lt;br /&gt;
//--&amp;gt;&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;form name=&quot;form1&quot; id=&quot;form1&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;select name=&quot;menu1&quot;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;onchange=&quot;MM_jumpMenu(&#39;parent&#39;,this,0)&quot;&lt;/span&gt;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;lt;option selected=&quot;selected&quot;&amp;gt;ระบุ&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;http://www.google.com&quot;&amp;gt;google&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/select&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
จาก &lt;b&gt;code&lt;/b&gt; ด้านบนที่เป็นตัวสีแดงจะเป็นการทำงานในส่วนของการเปิดหน้าต่างใหม่ เราก็แก้ไขเป็น&lt;b&gt;โค้ด&lt;/b&gt;ด้านล่างนี้แทน&lt;/div&gt;
onchange=&quot;window.open(this.options[this.selectedIndex].value,&#39;_blank&#39;)&quot;&lt;br /&gt;
คราวนี้เราก็จะได้ jump menu ที่เปิดหน้าต่างใหม่เป็นแบบ _self แล้วครับ&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/5960353769593053013/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/5960353769593053013' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/5960353769593053013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/5960353769593053013'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/07/jump-menu.html' title='การทำ jump menu เพื่อเปิดหน้าต่างใหม่'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-4438667506870857191</id><published>2012-06-27T09:16:00.000+07:00</published><updated>2012-06-27T09:16:20.648+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Google Maps API V.2"/><title type='text'>Google Maps api v2 - การนำพิกัดจากฐานข้อมูลมาแสดงบน Google Map</title><content type='html'>&lt;b&gt;บทความ&lt;/b&gt;นี้มาต่อไนเรื่องของ Google Map api v2 จากที่เคยกล่าวถึงในเรื่องของ&amp;nbsp;&lt;a href=&quot;http://hotcodephp.blogspot.com/2012/06/google-maps-api-v2-mysql-xml-marker.html&quot; target=&quot;_blank&quot;&gt;Google Maps api v2 - การเชื่อมต่อฐานข้อมูล เพื่อแปลง Mysql ให้เป็นไฟล์ Xml เพื่อใช้ในการสร้าง Marker บนแผนที่&lt;/a&gt;&amp;nbsp;มาแล้ว &lt;b&gt;บทความ&lt;/b&gt;นี้จะเป็นการนำ Marker มาแสดงผลบน Google Map ซึ่งเป็นการนำพิกัดที่ได้เก็บไว้มาแสดงผลเป็น Marker และ sidebar (แถบแสดงข้อมูลบนแผนที่) คำสั่งจะอยู่ในรูปของ&lt;b&gt;โค้ด&lt;/b&gt;ด้านล่างครับ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;
GDownloadUrl(&quot;phpsqlajax_markers.php&quot;, function(data) {&lt;br /&gt;
var  xml = GXml.parse(data);&lt;br /&gt;
var markers =  xml.documentElement.getElementsByTagName(&quot;marker&quot;);&lt;br /&gt;
var sidebar =  document.getElementById(&#39;sidebar&#39;);&lt;br /&gt;
sidebar.innerHTML = &#39;&#39;;&lt;br /&gt;
if  (markers.length == 0) {&lt;br /&gt;
sidebar.innerHTML = &#39;No results  found.&#39;;&lt;br /&gt;
return;&lt;br /&gt;
}&lt;br /&gt;
for (var i = 0; i &amp;lt; markers.length; i++) {&lt;br /&gt;
var  name = markers[i].getAttribute(&quot;name&quot;);&lt;br /&gt;
var address =  markers[i].getAttribute(&quot;address&quot;);&lt;br /&gt;
var type = &quot;cross&quot;;&lt;br /&gt;
var point = new  GLatLng(parseFloat(markers[i].getAttribute(&quot;lat&quot;)),&lt;br /&gt;
parseFloat(markers[i].getAttribute(&quot;lng&quot;)));&lt;br /&gt;
var  marker = createMarker(point, name, address,  type);&lt;br /&gt;
map.addOverlay(marker);&lt;br /&gt;
var sidebarEntry =  createSidebarEntry(marker, name,  address);&lt;br /&gt;
sidebar.appendChild(sidebarEntry);&lt;br /&gt;
bounds.extend(point) ;  &lt;br /&gt;
}&lt;br /&gt;
});&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function createMarker(point, name, address, type)  {&lt;br /&gt;
var marker = new GMarker(point, customIcons[type]);&lt;br /&gt;
var html =  &quot;&amp;lt;b&amp;gt;ชื่อสถานที่ : &quot; + name + &quot;&amp;lt;/b&amp;gt; &amp;lt;br/&amp;gt;ที่อยู่ : &quot; +  address;&lt;br /&gt;
GEvent.addListener(marker, &#39;click&#39;, function()  {&lt;br /&gt;
marker.openInfoWindowHtml(html);&lt;br /&gt;
}); return marker;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function  createSidebarEntry(marker, name, address) {&lt;br /&gt;
var div =  document.createElement(&#39;div&#39;);&lt;br /&gt;
var html = &quot;&amp;lt;b&amp;gt;ชื่อ : &quot; + name +  &quot;&amp;lt;/b&amp;gt; &amp;lt;br/&amp;gt;ที่อยู่ : &quot; + address ;&lt;br /&gt;
div.innerHTML =  html;&lt;br /&gt;
div.style.cursor = &#39;pointer&#39;;&lt;br /&gt;
div.style.marginBottom =  &#39;5px&#39;;&lt;br /&gt;
GEvent.addDomListener(div, &#39;click&#39;, function()  {&lt;br /&gt;
GEvent.trigger(marker, &#39;click&#39;);&lt;br /&gt;
});&lt;br /&gt;
GEvent.addDomListener(div,  &#39;mouseover&#39;, function() {&lt;br /&gt;
div.style.backgroundColor =  &#39;#eee&#39;;&lt;br /&gt;
});&lt;br /&gt;
GEvent.addDomListener(div, &#39;mouseout&#39;, function()  {&lt;br /&gt;
div.style.backgroundColor = &#39;#fff&#39;;&lt;br /&gt;
});&lt;br /&gt;
return div;&lt;br /&gt;
}&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
จาก&lt;b&gt;โค้ด&lt;/b&gt;ตัวอย่างนี้จะทำการโหลดข้อมูลจาก&lt;b&gt;บทความ&lt;/b&gt; &quot;&amp;nbsp;&lt;a href=&quot;http://hotcodephp.blogspot.com/2012/06/google-maps-api-v2-mysql-xml-marker.html&quot; target=&quot;_blank&quot;&gt;Google Maps api v2 - การเชื่อมต่อฐานข้อมูล เพื่อแปลง Mysql ให้เป็นไฟล์ Xml เพื่อใช้ในการสร้าง Marker บนแผนที่&lt;/a&gt;&quot;&amp;nbsp;&amp;nbsp;ขึ้นมาเพื่อทำการสร้าง Marker ขึ้นมาบนแผนที่  โดยข้อมูลจะถูกสร้างขึ้นมาและเก็บไว้ที่ตัวแปล sidebar เพื่อเก็บไว้ใช้แสดงข้อมูล  โดยคำสั่ง for (var i = 0; i &amp;lt; markers.length; i++)  จะทำการวนลูปสร้าง พิกัดขึ้นมาจนครบ และดึงข้อมูล name(ชื่อ), address(ที่อยู่), type(รูปแบบmarkerที่ให้แสดง) และ point(พิกัด)  เพื่อสำหรับเรียกใช้งานการแสดงผลของฟังชั้น  createMarker&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
function  createMarker เพื้อใช้ในการแสดงผล Marker ออกมาด้วยคำสั่ง  map.addOverlay(marker); และ&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
function createSidebarEntry  เพื้อสร้างการแสดงผลในส่วน body ของ Html  เพื่อเรียกใช้งานได้้ให้ไปสู่พิกัดที่เก็บไว้ได้ทันที่เมื่อเลือก เขียนไปเขียนมาก็งงลอง&lt;a href=&quot;http://www.mediafire.com/?hqi3d4yzvxk&quot; target=&quot;_blank&quot;&gt;โหลดตัวอย่าง&lt;/a&gt;ไปดูล่ะกันครับ&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/4438667506870857191/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/4438667506870857191' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/4438667506870857191'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/4438667506870857191'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/06/google-maps-api-v2-google-map.html' title='Google Maps api v2 - การนำพิกัดจากฐานข้อมูลมาแสดงบน Google Map'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-1967322601675101720</id><published>2012-06-26T11:48:00.001+07:00</published><updated>2012-06-26T11:48:20.786+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>code php กับการทำ dropdownlist 2 ขั้นอย่างง่าย</title><content type='html'>&lt;b&gt;บทความ&amp;nbsp;โค้ด php&lt;/b&gt; บทความนี้จะเกี่ยวกับการทำ dropdownlist แบบ 2 ชั้น ยกตัวอย่างเช่น ถ้าเราเลือกรายการใน listbox หลักแล้วใน listbox ย่อยก็จะแสดงรายการที่เกี่ยวข้องกับ listbox หลักขึ้นมานั่นเอง &amp;nbsp;คิดว่าคงมีหลายคนเคยใช้ หรือเคยค้นหาวิธีการทำอยู่บ้าง&lt;b&gt;โค้ด&lt;/b&gt;ที่นำมานี้จะเป็นการใช้&lt;b&gt;ภาษา php&lt;/b&gt; ในการเขียน และเชื่อมโยงฐานข้อมูลกับ MS Access แต่ก็สามารถนำไปประยุกต์ใช้กับฐานข้อมูล Sql ได้น่ะครับ ก็ลองนำโค้ดไปปรับแต่งดู&lt;br /&gt;
ตัวอย่าง Code php&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;script&amp;gt;&lt;br /&gt;
function submit_click(obj,s)&lt;br /&gt;
{&lt;br /&gt;
if(s==&#39;a&#39; &amp;amp; document.form_test.a.value!=&#39;&amp;lt;?=$a?&amp;gt;&#39;)&lt;br /&gt;
{&lt;br /&gt;
document.form_test.b.value=&quot;&quot;;&lt;br /&gt;
obj.action=&quot;&quot;;&lt;br /&gt;
obj.submit();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
else if(s==&#39;b&#39; &amp;amp; document.form_test.b.value!=&#39;&amp;lt;?=$b?&amp;gt;&#39;)&lt;br /&gt;
{&lt;br /&gt;
obj.action=&quot;&quot;;&lt;br /&gt;
obj.submit();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;lt;form name=&quot;form_test&quot; method=&quot;post&quot; action=&quot;insert.php&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;table width=&quot;50%&quot; border=&quot;2&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; bordercolor=&quot;#3366CC&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td width=&quot;40%&quot;&amp;gt;&amp;lt;div align=&quot;left&quot;&amp;gt;&amp;lt;strong&amp;gt;เลือกประเภทหลัก &amp;lt;/strong&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;select name=&quot;a&quot; onChange=&quot;submit_click(this.form,&#39;a&#39;)&quot; &amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;&amp;lt;?=$a?&amp;gt;&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;? if($a){echo&quot;$a&quot;;}else if(!$a){echo&quot;- เลือกประเภทหลัก -&quot;;}?&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;?&lt;br /&gt;
$dsn = &quot;&quot;;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; // กำหนดชื่อ DSN&lt;br /&gt;
$user =&quot;&quot;;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// กำหนดชื่อล็อกอิน&lt;br /&gt;
$pass =&quot;&quot;;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// กำหนดรหัสผ่าน&lt;br /&gt;
$connect = odbc_connect($dsn, $user, $pass) or die(&quot;ติดต่อ DSN ไม่ได้&quot;);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// เริ่มติดต่อฐานข้อมูล&lt;br /&gt;
$sql = &quot;SELECT other.total AS a&lt;br /&gt;
FROM other&lt;br /&gt;
GROUP BY other.total;&lt;br /&gt;
&amp;nbsp;&quot;;// กำหนดคำสั่ง SQL เพื่อแสดงข้อมูล&lt;br /&gt;
$exec = odbc_exec($connect, $sql);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// เริ่มเอ็กซิคิวต์คำสั่ง SQL&lt;br /&gt;
While (odbc_fetch_row($exec4))&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// ดึงข้อมูลเรกคอร์ดที่&lt;br /&gt;
{&lt;br /&gt;
$a1 = odbc_result($exec, &quot;a&quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;&amp;lt;?=$a1?&amp;gt;&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;?=$a1?&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;? } ?&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/select&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td width=&quot;40%&quot;&amp;gt;&amp;lt;div align=&quot;left&quot;&amp;gt;&amp;lt;strong&amp;gt;เลือกประเภทย่อย&amp;lt;/strong&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;select name=&quot;b&quot; onChange=&quot;submit_click(this.form,&#39;b&#39;)&quot; &amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;&amp;lt;?=$b?&amp;gt;&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;? if($b){echo&quot;$b&quot;;}else if(!$b){echo&quot;- เลือกประเภทย่อย -&quot;;}?&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;?&lt;br /&gt;
$sql1 =&quot;SELECT other.form AS b&lt;br /&gt;
FROM other&lt;br /&gt;
GROUP BY other.total, other.form&lt;br /&gt;
HAVING (((other.total)=&#39;$a&#39;));&lt;br /&gt;
&amp;nbsp;&quot;;// กำหนดคำสั่ง SQL เพื่อแสดงข้อมูล&lt;br /&gt;
$exec1 = odbc_exec($connect, $sql1);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// เริ่มเอ็กซิคิวต์คำสั่ง SQL&lt;br /&gt;
While (odbc_fetch_row($exec1))&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// ดึงข้อมูลเรกคอร์ดที่&lt;br /&gt;
{&lt;br /&gt;
$b1 = odbc_result($exec1, &quot;b&quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;option value=&quot;&amp;lt;?=$b1?&amp;gt;&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;?=$b1?&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;? } ?&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/select&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;td colspan=&quot;2&quot;&amp;gt;&amp;lt;div align=&quot;center&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;บันทึก&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;input name=&quot;btnClear&quot; type=&quot;reset&quot; id=&quot;btnClear&quot; value=&quot;Clear&quot; onClick=&quot;clsControlObject(&#39;form_test&#39;,&#39;clear&#39;)&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
ซึ่งถ้าเราเข้าใจการทำงานของคำสั่งดีแล้ว เราก็จะสามารถนำไปพัฒนาต่อเป็น 3 ชั้น หรือ 4 ชั้นได้ต่อไป&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/1967322601675101720/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/1967322601675101720' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/1967322601675101720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/1967322601675101720'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/06/code-php-dropdownlist-2.html' title='code php กับการทำ dropdownlist 2 ขั้นอย่างง่าย'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-8381655428176884560</id><published>2012-06-22T10:26:00.003+07:00</published><updated>2012-06-25T08:13:00.218+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Google Maps API V.2"/><title type='text'>Google Maps api v2 - การบันทึกข้อมูลลงฐานข้อมูล</title><content type='html'>หลังจากที่ศึกษา&amp;nbsp;&lt;b&gt;โค้ด php&lt;/b&gt; เกี่ยวกับ &lt;a href=&quot;http://google%20maps%20api%20v2%20-%20%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%80%E0%B8%8A%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%A1%E0%B8%95%E0%B9%88%E0%B8%AD%E0%B8%90%E0%B8%B2%E0%B8%99%E0%B8%82%E0%B9%89%E0%B8%AD%E0%B8%A1%E0%B8%B9%E0%B8%A5%20%E0%B9%80%E0%B8%9E%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B9%81%E0%B8%9B%E0%B8%A5%E0%B8%87%20mysql%20%E0%B9%83%E0%B8%AB%E0%B9%89%E0%B9%80%E0%B8%9B%E0%B9%87%E0%B8%99%E0%B9%84%E0%B8%9F%E0%B8%A5%E0%B9%8C%20xml%20%E0%B9%80%E0%B8%9E%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B9%83%E0%B8%99%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87%20marker%20%E0%B8%9A%E0%B8%99%E0%B9%81%E0%B8%9C%E0%B8%99%E0%B8%97%E0%B8%B5%E0%B9%88/&quot; target=&quot;_blank&quot;&gt;Google Maps api v2&lt;/a&gt; มาแล้ว วันนี้เรามาต่อในเรื่องของการบันทึกข้อมูลลงฐานข้อมูล ซึ่งมีวิธีทำหลัก ๆ อยู่ 2 วิธีคือ&lt;br /&gt;
&lt;div&gt;
1.ส่งค่าละติจูต และ ลองติจูต 
ไปอีกหน้าเพื่อกรอกข้อมูลที่เหลือเแล้วค่อยทำการบันทึกข้อมูล 
&lt;br /&gt;
2.บันทึกการกรอกข้อมูลจากหน้าแสดงแผนที่&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
เรามาเริ่มดู &lt;b&gt;code&lt;/b&gt; กันเลยครับ เริ่มจากการสร้างฐานข้อมูลเป็นอันดับแรกโค้ดด้านล่างเลยครับ&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;code&quot;&gt;
CREATE TABLE `markers` (&lt;br /&gt;
`id` INT NOT NULL AUTO_INCREMENT 
PRIMARY KEY ,&lt;br /&gt;
`name` VARCHAR( 60 ) NOT NULL ,&lt;br /&gt;
`address` VARCHAR( 80 ) NOT 
NULL ,&lt;br /&gt;
`lat` FLOAT( 10, 6 ) NOT NULL ,&lt;br /&gt;
`lng` FLOAT( 10, 6 ) NOT NULL 
,&lt;br /&gt;
`type` VARCHAR( 30 ) NOT NULL&lt;br /&gt;
) ENGINE = MYISAM ;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
หลังจากนั้นก็สร้างไฟล์หน้าแผนที่ขึ้นมาเพื่อเราจะได้ส่งค่าพิกัดไปได้ (&lt;a href=&quot;http://hotcodephp.blogspot.com/2012/05/google-maps-api-v2-2-3.html&quot; target=&quot;_blank&quot;&gt;ดูบทความการส่งค่าพิกัด&lt;/a&gt;)&amp;nbsp;&lt;span style=&quot;background-color: white;&quot;&gt;เมื่อสร้างหน้าส่งค่าเสร็จแล้วให้สร้างหน้ารับค่าเพื่อกรอกข้อมูลเพิ่มเติ่มขึ้นมา ซึ่งมี&lt;b&gt;โค้ด&lt;/b&gt;ตามข้างล้างนี้&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
โดยขอใช้&lt;b&gt;ภาษา php&lt;/b&gt; &amp;nbsp;ในการเขียนโปรแกรม&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;b&gt;code php&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;lt;?php&lt;br /&gt;
$lat = $_GET[&quot;lat&quot;];&lt;br /&gt;
$lng = 
$_GET[&quot;lng&quot;];&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;meta http-equiv=&quot;Content-Type&quot; 
content=&quot;text/html; charset=utf-8&quot; 
/&amp;gt;&lt;br /&gt;
&amp;lt;title&amp;gt;เพิ่มข้อมูลฟาร์มไก่&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;style 
type=&quot;text/css&quot;&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
body {&lt;br /&gt;
background-image: 
url(picture/page1952.jpg);&lt;br /&gt;
}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;/style&amp;gt;&amp;lt;/head&amp;gt; 
&amp;lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot; 
type=&quot;text/css&quot;&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;form action=&quot;ex_7c.php&quot; 
method=&quot;get&quot;&amp;gt;&lt;br /&gt;
&amp;lt;table width=&quot;442&quot; height=&quot;0&quot; border=&quot;0&quot; align=&quot;center&quot; 
cellpadding=&quot;2&quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td width=&quot;143&quot; align=&quot;right&quot; 
valign=&quot;top&quot;&amp;gt;ชื่อ&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td width=&quot;300&quot; valign=&quot;top&quot;&amp;gt;&amp;lt;div 
align=&quot;left&quot; &amp;gt;&lt;br /&gt;
&amp;lt;input type=&quot;text&quot; name=&quot;fname&quot; value= 
&quot;&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td 
align=&quot;right&quot; valign=&quot;top&quot;&amp;gt;ประเภท&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td 
valign=&quot;top&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;label&amp;gt;&lt;br /&gt;
&amp;lt;input name=&quot;type&quot; 
type=&quot;radio&quot; value=&quot;เปิด&quot; 
checked&amp;gt;&lt;br /&gt;
เปิด&amp;lt;/label&amp;gt;&lt;br /&gt;
&amp;lt;label&amp;gt;&lt;br /&gt;
&amp;lt;input name=&quot;type&quot; 
type=&quot;radio&quot; 
value=&quot;ปิด&quot;&amp;gt;&lt;br /&gt;
ปิด&amp;lt;/label&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td 
align=&quot;right&quot; valign=&quot;top&quot;&amp;gt;ที่อยู่&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td 
valign=&quot;top&quot;&amp;gt;&amp;lt;div align=&quot;left&quot;&amp;gt;&lt;br /&gt;
&amp;lt;textarea name=&quot;faddress&quot; 
cols=&quot;30&quot; rows=&quot;10&quot; class=&quot;textarea&quot; 
&amp;gt;Address&amp;lt;/textarea&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td 
align=&quot;right&quot; valign=&quot;top&quot;&amp;gt;ละติจูต&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td 
valign=&quot;top&quot;&amp;gt;&amp;lt;div align=&quot;left&quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&quot;text&quot; name=&quot;flat&quot; 
value=&amp;lt;? echo $lat ?&amp;gt; 
/&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td 
align=&quot;right&quot; valign=&quot;top&quot;&amp;gt;ลองติจูต&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td 
valign=&quot;top&quot;&amp;gt;&amp;lt;div align=&quot;left&quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&quot;text&quot; name=&quot;flng&quot; 
value=&amp;lt;? echo $lng ?&amp;gt; 
/&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td 
colspan=&quot;2&quot; align=&quot;center&quot;&amp;gt;&amp;lt;div align=&quot;center&quot;&amp;gt;&lt;br /&gt;
&amp;lt;input 
type=&quot;submit&quot; name=&quot;button&quot; value=&quot;ทำการเพิ่มรายชื่อฟาร์ม&quot; 
/&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;และสุดท้าย ให้สร้างหน้าไฟล์เพื่อทำการบันทึกข้อมูลลง&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Mysql&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;b&gt;code php&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;lt;?php 
require(&quot;phpsql_dbinfo.php&quot;);&lt;br /&gt;
$con =mysql_connect ($hostname, $username, 
$password);&lt;br /&gt;
mysql_query(&quot;SET NAMES UTF8&quot;,$con); &lt;br /&gt;
if (!$con) { die(&#39;ติดต่อฐานข้อมูลไม่ได้: &#39; . 
mysql_error());&lt;br /&gt;
}&lt;br /&gt;
mysql_select_db($database, $con);&lt;br /&gt;
$sql = mysql_query(&quot;INSERT INTO markers (name, address, type, flat, 
flng)&lt;br /&gt;
VALUES(&#39;$_GET[name]&#39;,&#39;$_GET[address]&#39;,&#39;$_GET[type]&#39;,$_GET[flat],$_GET[flng]) 
&quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div 
align=&quot;center&quot;&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;&amp;amp;nbsp; 
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;table width=&quot;200&quot; 
border=&quot;0&quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;div align=&quot;center&quot;&amp;gt; 
บันทึกข้อมูลเรียบร้อย 
&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;amp;nbsp;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span class=&quot;style1&quot;&gt;***หมายเหตุ การส่งข้อมูลไปเก็บทีื่่ Mysql 
และการเรียกใช้ข้อมูลจาก Mysql ที่เป็นภาษาไทยไม่ให้ภาษาผิดเพี้ยนให้ใส่tagคำสั่ง 
&lt;br /&gt;mysql_query(&quot;SET NAMES UTF8&quot;,$con); ลงไปหลังคำสั่งเชื่อมต่อ mysql_connect 
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;****และต้องกำหนดตัวอักษรของฐานข้อมูลเป็นประเภท UTF8 
เท้านั้น (จะเป็นUTF8แบบใหนก็ได้)&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/8381655428176884560/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/8381655428176884560' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/8381655428176884560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/8381655428176884560'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/06/google-maps-api-v2.html' title='Google Maps api v2 - การบันทึกข้อมูลลงฐานข้อมูล'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-1956380531906478325</id><published>2012-06-07T08:30:00.001+07:00</published><updated>2012-06-11T12:56:46.572+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Google Maps API V.2"/><title type='text'>Google Maps api v2 - การเชื่อมต่อฐานข้อมูล เพื่อแปลง Mysql ให้เป็นไฟล์ Xml เพื่อใช้ในการสร้าง Marker บนแผนที่</title><content type='html'>&lt;br /&gt;
ในบทความนี้จะเป็นการนำฐานข้อมูลของเราที่มีการเก็บพิกัดไว้ มาใช้ร่วมกับ Google map api v2 โดยใช้&lt;b&gt;ภาษา php&lt;/b&gt; การเขียนคำสั่งของ&lt;b&gt;โค้ด php&lt;/b&gt; นั้นเพื่อความสะดวกในการใช้งานควรจะสร้างไฟล์เชื่อมต่อ Mysql แยกไว้ 1 ไฟล์โดยสมมุติว่าชื่อ phpsql_dbinfo.php เมื่อต้องการใช้ก็ให้ทำการ require(&quot;phpsqlinfo_dbinfo.php&quot;); โดยประกาศตัวแปลดังนี้ (สมมุติว่าใช้บน localhost)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;code php&lt;/b&gt; ไฟล์ phpsql_dbinfo.php&lt;br /&gt;
&lt;br /&gt;
$username=&quot;(ปกติรันบนlocalhostมักจะเป็นคำว่า &amp;nbsp;root)&quot;;&lt;br /&gt;
$password=&quot;(ใส่ตามที่ตั้งไว้)&quot;;&lt;br /&gt;
$database=&quot;(ใส่ชื่อฐานข้อมูล)&quot;;&lt;br /&gt;
$hostname &amp;nbsp;= &quot;(ปกติรันบนlocalhostก็ใช้คำว่าlocalhost)&quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
จากนั้นสำหรับการเปลี่ยนจากฐานข้อมูล Mysql ให้เป็น Xml (โดยในที่นี้คือไฟล์ phpsqlajax_markers.php ซึ่งจะถูกเรียกใช้ในตัวอย่างต่อๆไป)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;code php&lt;/b&gt; phpsqlajax_markers.php&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
require(&quot;phpsqlinfo_dbinfo.php&quot;);&lt;br /&gt;
&lt;br /&gt;
function parseToXML($htmlStr)&lt;br /&gt;
{&lt;br /&gt;
$xmlStr=str_replace(&#39;&amp;lt;&#39;,&#39;&amp;amp;lt;&#39;,$htmlStr);&lt;br /&gt;
$xmlStr=str_replace(&#39;&amp;gt;&#39;,&#39;&amp;amp;gt;&#39;,$xmlStr);&lt;br /&gt;
$xmlStr=str_replace(&#39;&quot;&#39;,&#39;&amp;amp;quot;&#39;,$xmlStr);&lt;br /&gt;
$xmlStr=str_replace(&quot;&#39;&quot;,&#39;&amp;amp;#39;&#39;,$xmlStr);&lt;br /&gt;
$xmlStr=str_replace(&quot;&amp;amp;&quot;,&#39;&amp;amp;amp;&#39;,$xmlStr);&lt;br /&gt;
return $xmlStr;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$connection=mysql_connect ($hostname, $username, $password);&lt;br /&gt;
mysql_query(&quot;SET NAMES UTF8&quot;,$connection);&lt;br /&gt;
if (!$connection) {&lt;br /&gt;
die(&#39;Not connected : &#39; . mysql_error());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$db_selected = mysql_select_db($database, $connection);&lt;br /&gt;
if (!$db_selected) {&lt;br /&gt;
die (&#39;Can\&#39;t use db : &#39; . mysql_error());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$query = &quot;SELECT * FROM markers WHERE 1&quot;;&lt;br /&gt;
$result = mysql_query($query);&lt;br /&gt;
if (!$result) {&lt;br /&gt;
die(&#39;Invalid query: &#39; . mysql_error());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
header(&quot;Content-type: text/xml&quot;);&lt;br /&gt;
&lt;br /&gt;
// Start XML file, echo parent node&lt;br /&gt;
echo &#39;&amp;lt;markers&amp;gt;&#39;;&lt;br /&gt;
// Iterate through the rows, printing XML nodes for each&lt;br /&gt;
while ($row = @mysql_fetch_assoc($result)){&lt;br /&gt;
// ADD TO XML DOCUMENT NODE&lt;br /&gt;
echo &#39;&amp;lt;marker &#39;;&lt;br /&gt;
echo &#39;name=&quot;&#39; . parseToXML($row[&#39;name&#39;]) . &#39;&quot; &#39;;&lt;br /&gt;
echo &#39;address=&quot;&#39; . $row[&#39;address&#39;] . &#39;&quot; &#39;;&lt;br /&gt;
echo &#39;lat=&quot;&#39; . $row[&#39;lat&#39;] . &#39;&quot; &#39;;&lt;br /&gt;
echo &#39;lng=&quot;&#39; . $row[&#39;lng&#39;] . &#39;&quot; &#39;;&lt;br /&gt;
echo &#39;type=&quot;&#39; . $row[&#39;type&#39;] . &#39;&quot; &#39;;&lt;br /&gt;
echo &#39;/&amp;gt;&#39;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// End XML file&lt;br /&gt;
echo &#39;&amp;lt;/markers&amp;gt;&#39;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
จากตัวอย่างจะเห็นได้ว่าเมื่อเชื่อมต่อแล้วประกาศ header(&quot;Content-type: text/xml&quot;);แล้วก็จะสามารถใส่เงื่อนไขการแสดงข้อมูลออกมาได้ตามควมต้องการ&lt;br /&gt;
***หมายเหตุ การส่งข้อมูลไปเก็บทีื่่ Mysql และการเรียกใช้ข้อมูลจาก Mysql ที่เป็นภาษาไทยไม่ให้ภาษาผิดเพี้ยนให้ใส่ tag คำสั่ง mysql_query(&quot;SET NAMES UTF8&quot;,$con); ลงไปหลังคำสั่งเชื่อมต่อ mysql_connect&lt;br /&gt;
****และต้องกำหนดตัวอักษรของฐานข้อมูลเป็นประเภท UTF8 เท้านั้น(จะเป็น UTF8 แบบใหนก็ได้)&lt;br /&gt;
&lt;br /&gt;
ดังนั้นในตอนนี้เราก็จะได้ข้อมูลที่แปลงจากฐาน mysql เป็น xml ได้แล้ว ในบทความต่อไปผมจะนำตัวอย่างของโค้ด php ที่นำข้อมูล xml ไปแสดงบน google map api v2 ครับ&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/1956380531906478325/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/1956380531906478325' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/1956380531906478325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/1956380531906478325'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/06/google-maps-api-v2-mysql-xml-marker.html' title='Google Maps api v2 - การเชื่อมต่อฐานข้อมูล เพื่อแปลง Mysql ให้เป็นไฟล์ Xml เพื่อใช้ในการสร้าง Marker บนแผนที่'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-2881875869237979665</id><published>2012-06-05T12:35:00.000+07:00</published><updated>2012-06-06T08:09:36.344+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Google Maps API V.2"/><title type='text'>Google Maps api v2 - การสร้างและปรับแต่ง Marker</title><content type='html'>วันนี้เราต่อเรื่อง Google Maps API V2 หลังจากที่หายไปนาน ใครลืมไปแล้วเข้าไปดูเรื่องเก่าได้ &lt;a href=&quot;http://hotcodephp.blogspot.com/search/label/Google%20Maps%20API%20V.2&quot;&gt;ที่นี่&lt;/a&gt;&amp;nbsp;&lt;b&gt;โค้ด&lt;/b&gt;ตัวนี้จะเป็นในเรื่องของการสร้างและปรับแต่ง Marker ด้วยการคลิกบนแผนที่ ผมขอใช้&lt;b&gt;ภาษา php&lt;/b&gt; ในการเขียน&lt;b&gt;โค้ด php&lt;/b&gt; น่ะครับ โค้ดคำสั่งในการเรียกใช้งานคือ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;
GEvent.addListener(map, &quot;click&quot;, function(marker, point) 
{&lt;br /&gt;
map.addOverlay(new GMarker(point));});&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;span class=&quot;code&quot;&gt;map.addOverlay(new GMarker(point));&lt;/span&gt; 
คือคำสั่งในการสร้าง Marker sซึ่งเราสามารถปรับแต่ งMarkers ได้เองดังตัวอย่าง&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;div class=&quot;code&quot;&gt;
var icongreen = new GIcon(); &lt;br /&gt;
icongreen.image = 
&#39;http://newsirius13.thport.com/picture/c003.png&#39;;&lt;br /&gt;
icongreen.shadow = 
&#39;http://labs.google.com/ridefinder/images/mm_20_shadow.png&#39;;&lt;br /&gt;
icongreen.iconSize 
= new GSize(20, 22);&lt;br /&gt;
icongreen.shadowSize = new GSize(1, 
1);&lt;br /&gt;
icongreen.iconAnchor = new GPoint(12, 8);&lt;br /&gt;
icongreen.infoWindowAnchor = 
new GPoint(5, 1);&lt;br /&gt;
&lt;br /&gt;
GEvent.addListener(map, &quot;click&quot;, function(marker, 
point) {&lt;br /&gt;
map.addOverlay(new GMarker(point, icongreen));});&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
ในตัวอย่างนี้จำทำการสร้างตัวแปลขึ้นมา1ตัว ชื่อ icongreen 
เพื่อเก็บการตั้งค่าต่างๆของ Markers และเรียกใช้โดยให้ใส่ตัวแปลลงไปในคำสังสร้างMarkerนั้นคือ new GMarker(point, 
&quot;ใส่ตัวแปลที่ต้องการ (ในตัวอย่างคือicongreen)&quot;) ก็จะได้ 
Markersตามรูปแบบที่เราได้ปรับแต่งตามต้องการ&lt;br /&gt;
&lt;br /&gt;
ส่วนอันนี้เป็นตัวอย่างการใช้งานทั้งหมดน่ะครับ&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:v=&quot;urn:schemas-microsoft-com:vml&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;lt;head&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;title&amp;gt;newsirius13&amp;lt;/title&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;sensor=false&amp;amp;amp;key=ABQIAAAAKaJQ6galA0QmFhNdQzYuwRQnaT__a1y-hZdnJBN4Ggj_4W3wVRTkKlGxp0EJvRTbiAqcn-FCYSTDog&quot;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; type=&quot;text/javascript&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; var icongreen = new GIcon();&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; icongreen.image = &#39;http://newsirius13.thport.com/picture/c003.png&#39;;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; icongreen.shadow = &#39;http://labs.google.com/ridefinder/images/mm_20_shadow.png&#39;;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; icongreen.iconSize = new GSize(20, 22);&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; icongreen.shadowSize = new GSize(1, 1);&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; icongreen.iconAnchor = new GPoint(12, 8);&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; icongreen.infoWindowAnchor = new GPoint(5, 1);&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp;function initialize() {&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if (GBrowserIsCompatible()) {&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var map = new GMap2(document.getElementById(&quot;map_canvas&quot;));&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; map.setCenter(new GLatLng(13.8196,100.0601), 7);&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;GEvent.addListener(map, &quot;click&quot;, function(marker, point) {&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;map.addOverlay(new GMarker(point, icongreen));});&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; map.addControl(new GLargeMapControl());&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; map.addControl(new GMapTypeControl());&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;lt;/head&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;lt;body onload=&quot;initialize()&quot; onunload=&quot;GUnload()&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;div id=&quot;map_canvas&quot; style=&quot;width: 800px; height: 500px&quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;nbsp; &amp;lt;/body&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&amp;lt;/html&amp;gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code&quot;&gt;
ให้กดคลิกบนแผนที่จะทำการสร้างMarker ขึ้นมา&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/2881875869237979665/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/2881875869237979665' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/2881875869237979665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/2881875869237979665'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/06/google-maps-api-v2-marker.html' title='Google Maps api v2 - การสร้างและปรับแต่ง Marker'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-8990903257233112058</id><published>2012-05-25T15:46:00.001+07:00</published><updated>2012-05-28T13:25:45.449+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>ทำ text box ให้รับเฉพาะภาษาอังกฤษ</title><content type='html'>เป็นการทำ text box ให้ผู้ใช้งานกรอกได้เฉพาะข้อความ ภาษาอังกฤษเท่านั้น หากไม่ใช้ภาษาอังกฤษก็จะมีข้อความเตือนโค้ดด้านล่างเลยครับ&lt;br /&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;html&quot;&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;content-action&quot;&gt;
&lt;span class=&quot;html&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;html&quot;&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;form action=&quot;&quot; method=&quot;POST&quot; 
onsubmit=&quot;return checkeng()&quot; name=&quot;frm_test&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;input type=&quot;text&quot; name=&quot;test&quot;&amp;gt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;&amp;lt;input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;submit&quot; 
/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;script&quot;&gt;&amp;lt;script language=&quot;Javascript&quot; 
type=&quot;text/javascript&quot;&amp;gt;&lt;br /&gt;function checkeng() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;var 
obj=frm_test.test&lt;br /&gt;&amp;nbsp;&amp;nbsp;var str=&quot;abcdefghijklmnopqrstuvwxyz&quot; &lt;span class=&quot;comment&quot;&gt;//ใส่ตัวอักษรที่มีได้ลงในนี้&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;var 
val=obj.value&lt;br /&gt;&amp;nbsp;&amp;nbsp;var valOK = true;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;for (i=0; i&amp;lt;val.length 
&amp;amp; valOK; i++){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;valOK = (str.indexOf(val.charAt(i))!= -1) 
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;alert(valOK)&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;if (!valOK) 
{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;alert(&quot;ภาษาอังกฤษเท่านั้น&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;obj.focus()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 
false&lt;br /&gt;&amp;nbsp;&amp;nbsp;} return true&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/8990903257233112058/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/8990903257233112058' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/8990903257233112058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/8990903257233112058'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/05/text-box.html' title='ทำ text box ให้รับเฉพาะภาษาอังกฤษ'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-4079022937938192674</id><published>2012-05-25T15:42:00.002+07:00</published><updated>2012-05-28T13:26:27.260+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>การทำ popup window</title><content type='html'>เป็นการเขียน&lt;b&gt;โค้ด&lt;/b&gt;เพื่อเปิด popup window ที่ไม่มี ทั้ง menu, toolbar และ status bar ครับ ตัวอย่างด่านล้างเลยครับจะนำไปวางโดยใช้&lt;b&gt;ภาษา php&lt;/b&gt; หรือ html ก็ได้แต่ตัวอย่างนี้ขอเป็น&lt;b&gt;โค้ด php&lt;/b&gt; น่ะครับ&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;script&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;script&quot;&gt;&amp;lt;script&amp;gt;&lt;br /&gt;var win = 
null;&lt;br /&gt;function popupwindow(filename, windowname, w, h) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;var winl = 
(screen.width-w)/2;&lt;br /&gt;&amp;nbsp;&amp;nbsp;var wint = (screen.height-h)/2;&lt;br /&gt;&amp;nbsp;&amp;nbsp;if (winl &amp;lt; 0) 
winl = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;if (wint &amp;lt; 0) wint = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;var settings = &#39;height=&#39; + h + 
&#39;,&#39;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;settings += &#39;width=&#39; + w + &#39;,&#39;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;settings += &#39;top=&#39; + wint + 
&#39;,&#39;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;settings += &#39;left=&#39; + winl + &#39;,&#39;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;settings += &#39;resizable=0, 
scrollbars=0, status=0,toolbar=0, menubars=0, location=0&#39;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;win = 
window.open(&#39;./&#39;+filename, windowname, 
settings);&lt;br /&gt;&amp;nbsp;&amp;nbsp;win.window.focus();&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;script&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;script&quot;&gt;อันนี้วิธีใช้ครับ&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;script&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;script&quot;&gt;&amp;lt;script&amp;gt;popupwindow(&quot;test.php?xxx=xx&quot;, &quot;_blank&quot;, 200, 
300)&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/4079022937938192674/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/4079022937938192674' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/4079022937938192674'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/4079022937938192674'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/05/popup-window.html' title='การทำ popup window'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-3342376547212563677</id><published>2012-05-25T09:04:00.000+07:00</published><updated>2012-05-28T13:27:07.445+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>การแก้ไขข้อมูลที่เป็น textfile บน web page</title><content type='html'>บทความนี้เป็นการใช้&lt;b&gt;โค้ด php&lt;/b&gt; เพื่อช่วยในการแก้ไขข้อมูลที่เป็น text file โดยที่เราไม่จำเป็นต้อง upload หรือ download สามารถแก้ไขได้บน web page ได้เลย&lt;br /&gt;
ตัวอย่าง &lt;b&gt;Code php&lt;/b&gt; นี้เป็นการแก้ไขไฟล์ c-main.txt ครับ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;meta 
http-equiv=&quot;Content-Type&quot;content=&quot;text/html;charset=utf-8&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;table align=&quot;center&quot; border=&quot;0&quot; width=&quot;100%&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;&amp;lt;td 
align=&quot;center&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;php&quot;&gt;&amp;lt;?&lt;br /&gt;$detail=$_POST[detail];&lt;br /&gt;if (isset($detail)) 
{&lt;br /&gt;$f=fopen(&quot;c-main.txt&quot;, &quot;wb&quot;);&lt;br /&gt;flock($f, 2);&lt;br /&gt;fwrite($f, 
$detail);&lt;br /&gt;flock($f, 3);&lt;br /&gt;fclose($f);&lt;br /&gt;echo 
&quot;แก้ไขข้อความเรียบร้อย&quot;;&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;&amp;lt;td 
align=&quot;center&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;table align=&quot;center&quot; 
border=&quot;0&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;form method=&quot;post&quot; 
action=&quot;news.php&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;&amp;lt;td align=&quot;center&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;textarea 
rows=&quot;25&quot; cols=&quot;100&quot; name=&quot;detail&quot; class=&quot;black&quot;&amp;gt;&lt;/span&gt;&lt;span class=&quot;php&quot;&gt;&amp;lt;? 
include(&quot;c-main.txt&quot;) ?&amp;gt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;&amp;lt;/textarea&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;&amp;lt;td align=&quot;right&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;input 
type=submit value=&#39;แก้ไข&#39; name=&quot;submit&quot; class=black&amp;gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;html&quot;&gt;&amp;lt;input type=reset value=&#39;เคลียร์&#39; name=&quot;reset&quot; 
class=black&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/3342376547212563677/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/3342376547212563677' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/3342376547212563677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/3342376547212563677'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/05/textfile-web-page.html' title='การแก้ไขข้อมูลที่เป็น textfile บน web page'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-6921863050974361255</id><published>2012-05-25T08:56:00.002+07:00</published><updated>2012-05-28T13:27:32.401+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>แบ่งไฟล์ข้อมูลขนาดใหญ่ออกเป็นไฟล์เล็กๆ ด้วย PHP</title><content type='html'>ในการ upload ข้อมูลเข้าสู่ฐานข้อมูลถ้าข้อมูลมีขนาดใหญ่อาจใช้เวลานานในการ upload หรือในบางครั้งเครื่องอาจจะค้างไปเลยทำให้ต้องเสียเวลา upload ใหม่ ดังนั้นบทความนี้จะขอเสนอ&lt;b&gt;โค้ด php&lt;/b&gt; ซึ่งเป็นการแบ่งฐานข้อมูลออกเป็นไฟล์เล็กๆ ให้อัปโหลดง่ายขึ้น และก็ยัง query 
เข้าฐานข้อมูลได้ง่ายขึ้นด้วยครับ&lt;br /&gt;
&lt;b&gt;ตัวอย่าง Code php&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;php&quot;&gt;&amp;lt;?&lt;br /&gt;set_time_limit(0);&lt;br /&gt;$arr = 
file(&quot;C:/articles/articles.sql&quot;); &lt;span class=&quot;comment&quot;&gt;//ไฟล์ข้อมูลหลักที่ต้องการแยก&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;$records = 
count($arr);&lt;br /&gt;$split = 1000; &lt;span class=&quot;comment&quot;&gt;//แบ่งออกไฟล์ละ 1000 
บรรทัด&lt;/span&gt;&lt;br /&gt;$total = (int)($records / $split);&lt;br /&gt;if ($total * $split &amp;lt; 
$records) $total++;&lt;br /&gt;&lt;br /&gt;$n = 0; &lt;span class=&quot;comment&quot;&gt;//ชื่อไฟล์เริ่มต้น 
C:/0.sql....C:/9.sql&lt;/span&gt;&lt;br /&gt;for ($i = 0; $i &amp;lt; $total; $i++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;$q = 
0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;$f = fopen(&quot;C:/$i.sql&quot;, &quot;wb&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;while ($n &amp;lt; $records &amp;amp; $q 
&amp;lt; $split) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;fputs($f, 
$arr[$n]);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$n++;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$q++;&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;fclose($f);&lt;br /&gt;} 
&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;php&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;php&quot;&gt;ผลลัพท์จะได้เป็นไฟล์ 0.sql, 1.sql....ไปเรื่อยๆ จนกว่าจะหมด ที่ drive C ครับ ก็ 
run code นี้ ควรตรวจสอบไดร์ฟ C ให้เรียบร้อยก่อนครับ&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/6921863050974361255/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/6921863050974361255' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/6921863050974361255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/6921863050974361255'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/05/php_25.html' title='แบ่งไฟล์ข้อมูลขนาดใหญ่ออกเป็นไฟล์เล็กๆ ด้วย PHP'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4940864674009916360.post-5807668257607616462</id><published>2012-05-25T08:49:00.002+07:00</published><updated>2012-05-28T13:28:04.998+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>ทำข้อความเตือนยืนยันการลบข้อมูล</title><content type='html'>การทำ form สำหรับการลบข้อมูลในฐานข้อมูล ในบางครั้งผู้ใช้งานอาจจะเผลอกดปุ่มลบไปโดยไม่รู้ตัวข้อมูลก็จะหายไปในทันที ดังนั้นจึงจำเป็นที่จะต้องมีโค้ดมาช่วยป้องกันอีกชั้น ซึ่ง&lt;b&gt;โค้ด&lt;/b&gt;ก็ไม่ได้มีอะไรมากอาจจะใช้&lt;b&gt;โค้ด php&lt;/b&gt; หรือ html ก็ได้แล้วแต่ถนัด&lt;br /&gt;
&lt;b&gt;Code php&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;form 
action=&quot;xxx.php&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;input type=submit 
name=submit value=delete onClick=&#39;return confirm()&#39;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;html&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;script&quot;&gt;&amp;lt;script 
language=&quot;JavaScript&quot;&amp;gt;&lt;br /&gt;function confirm(num)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;var 
x=window.confirm(&quot;คุณแน่ใจ ที่จะลบรายการนี้&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;return 
(x);&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;script&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;content-code&quot;&gt;
&lt;span class=&quot;script&quot;&gt;ถ้าคลิกตกลงจะไปทำตามคำสั่ง action ของฟอร์มตามปกติ&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hotcodephp.blogspot.com/feeds/5807668257607616462/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4940864674009916360/5807668257607616462' title='2 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/5807668257607616462'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4940864674009916360/posts/default/5807668257607616462'/><link rel='alternate' type='text/html' href='http://hotcodephp.blogspot.com/2012/05/blog-post_25.html' title='ทำข้อความเตือนยืนยันการลบข้อมูล'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry></feed>