ผลต่างระหว่างรุ่นของ "คู่มือการพัฒนาซอฟต์แวร์บนเว็บบราวซ์เซอร์ให้รองรับ UA ด้วยภาษา PHP/en"

จาก Wiki_EAI
ไปยังการนำทาง ไปยังการค้นหา
(กำลังอัพเดตเพื่อทำให้ตรงกันกับรุ่นปรับปรุงใหม่ของหน้่าโค้ดหลัก)
 
(ไม่แสดง 6 รุ่นระหว่างกลางโดยผู้ใช้ 2 คน)
แถว 3: แถว 3:
  
  
User/Pass for accessing server in the workshop  [[https://คน.ไทย/วิกิ/list-user-ws.jpg User]]  
+
<!--
 +
 
 +
User/Pass สำหรับเข้าเซิร์ฟเวอร์ใน workshop  [[https://คน.ไทย/วิกิ/list-user-ws.jpg User]]  
 
  # HOST: https://ws.kon.in.th
 
  # HOST: https://ws.kon.in.th
 
  # DB: https://ws.kon.in.th/phpmyadmin/
 
  # DB: https://ws.kon.in.th/phpmyadmin/
 
  # user: userX
 
  # user: userX
 
  # pass: eaiuserX
 
  # pass: eaiuserX
 +
 +
-->
  
 
== Preparing to Support UA in PHP ==
 
== Preparing to Support UA in PHP ==
แถว 13: แถว 17:
  
 
=== Related systems ===
 
=== Related systems ===
# Database system
+
# Database system
 
#* MySQL
 
#* MySQL
 
#* PHPMyAdmin
 
#* PHPMyAdmin
แถว 23: แถว 27:
 
#* PHPMailer
 
#* PHPMailer
  
=== To be used software  ===
+
=== Required software  ===
 
# Filezilla [[https://dl4.cdn.filezilla-project.org/client/FileZilla_3.52.2_win64-setup.exe?h=nRlrhWw7NLjal-h8S-C__A&x=1615717392 Win]] [[https://dl4.cdn.filezilla-project.org/client/FileZilla_3.52.2_macosx-x86.app.tar.bz2?h=jSIej0fAkYK7rWgFBbsUPA&x=1615717392 Mac]]
 
# Filezilla [[https://dl4.cdn.filezilla-project.org/client/FileZilla_3.52.2_win64-setup.exe?h=nRlrhWw7NLjal-h8S-C__A&x=1615717392 Win]] [[https://dl4.cdn.filezilla-project.org/client/FileZilla_3.52.2_macosx-x86.app.tar.bz2?h=jSIej0fAkYK7rWgFBbsUPA&x=1615717392 Mac]]
 
# Web Browser e.g. Firefox, Chrome, Safari
 
# Web Browser e.g. Firefox, Chrome, Safari
 
# Text Editor (Code Editor) e.g. Notepad, Atom
 
# Text Editor (Code Editor) e.g. Notepad, Atom
  
=== Application Architecture ===
+
=== Source code ===
 +
* Source code used in this workshop [[https://github.com/THNICF/UA-Workshop-12062021 source code]]
 +
 
 +
== Application Architecture ==
 
[[File:App-archetiect-3.png|400px]]
 
[[File:App-archetiect-3.png|400px]]
 
[[File:App-archetiect-2.png|400px]]
 
[[File:App-archetiect-2.png|400px]]
แถว 73: แถว 80:
 
  '''  default:  
 
  '''  default:  
 
  '''  return (bool) preg_match(&quot;/^[ก-๙a-zA-Z0-9_+&*-]+(?:\.[ก-๙a-zA-Z0-9_+&*-]+)*@(?:[ก-๙a-zA-Z0-9-]+\.)+[ก-๙a-zA-Z]{2,16}$/u&quot;, $address);
 
  '''  return (bool) preg_match(&quot;/^[ก-๙a-zA-Z0-9_+&*-]+(?:\.[ก-๙a-zA-Z0-9_+&*-]+)*@(?:[ก-๙a-zA-Z0-9-]+\.)+[ก-๙a-zA-Z]{2,16}$/u&quot;, $address);
 +
 +
The regular expression works for Thai email address only. For general email verification for any email addresses in any language, the following expression may be considered:
 +
 +
* something@something  ^(.+)@(.+)$
 +
  
 
[[Category: EAI]]
 
[[Category: EAI]]

รุ่นแก้ไขปัจจุบันเมื่อ 15:15, 6 ตุลาคม 2564

ภาษาอื่น ๆ:
English • ‎ไทย

This manual is a guideline for UA web application development using PHP. The application will be able to accept, validate and process Thai IDN and Thai EAI correctly.


Preparing to Support UA in PHP

Related systems

  1. Database system
    • MySQL
    • PHPMyAdmin
  2. Web application
    • Registration system
    • Login system
    • User profile system
  3. Email system
    • PHPMailer

Required software

  1. Filezilla [Win] [Mac]
  2. Web Browser e.g. Firefox, Chrome, Safari
  3. Text Editor (Code Editor) e.g. Notepad, Atom

Source code

Application Architecture

App-archetiect-3.png App-archetiect-2.png App-archetiect-1.png

Developing Applications to Support UA in PHP

Cereate database that could handle IDN and EAI

# CREATE TABLE IF NOT EXISTS accounts ( 
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `username` varchar(50) NOT NULL,
   `password` varchar(255) NOT NULL,
   `email` varchar(100) NOT NULL,
   `activation_code` varchar(50) DEFAULT '',
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

modify the registration system to be able to accept EAI email address

modify register.html fronm

# <input type="email" name="email" placeholder="Email" id="email" required>

to

# <input type="text" name="email" placeholder="Email" id="email" required>

modifythe registration system to be able to validate EAI email address

modify register.php from

# if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { 

      exit('Email is not valid!');
 
  }

to

# if (preg_match('/^[ก-๙a-zA-Z0-9_+&*-]+(?:\.[ก-๙a-zA-Z0-9_+&*-]+)*@(?:[ก-๙a-zA-Z0-9-]+\.)+[ก-๙a-zA-Z]{2,16}$/u', $_POST['email']) == 0) {
      exit('Email is not valid!');
 
 }

modify the registration system to be able to send EAI email with PHPMailer

modify PHPMailer/src/PHPMailer.php from

# case 'php': 
  default:
  return filter_var($address, FILTER_VALIDATE_EMAIL) !== false;

to

# case 'php': 
  default: 
  return (bool) preg_match("/^[ก-๙a-zA-Z0-9_+&*-]+(?:\.[ก-๙a-zA-Z0-9_+&*-]+)*@(?:[ก-๙a-zA-Z0-9-]+\.)+[ก-๙a-zA-Z]{2,16}$/u", $address);

The regular expression works for Thai email address only. For general email verification for any email addresses in any language, the following expression may be considered:

  • something@something ^(.+)@(.+)$