SlideShare une entreprise Scribd logo
1  sur  35
Télécharger pour lire hors ligne
ก F ก F PHP
HTML Form
ก F ก F PHP
projetcsoft.biz F F ก
Tag Form
Tag input F F F tag form
Tag form ˈ F F F F F F F tag input F
.php.php
ก F F F ก F F .php F
Form .PHP file
projetcsoft.biz F F ก
Tag Form
Attribute ˈ F tag form method, action
Attribute action F ก F F form
file file
Attribute method F ก F F F form ˈ GET
( F address bar F index.php?id=1&name=John )( F address bar F index.php?id=1&name=John )
POST ( F F address bar)
Tag form ˈ F tag <input type=“submit” />
projetcsoft.biz F F ก
Tag Form
<form action= F F ก .php method=GET
POST>
……
……
</form></form>
projetcsoft.biz F F ก
Tag input type submit
Tag input Attribute type ˈ submit ˈ ˁ ก
Attribute value F ˁ
Tag input type submit F F F tag form
F F F ก ˁ submit form F browser ʽ F
ก F Attribute action formก F Attribute action form
projetcsoft.biz F F ก
Tag Form
<form action="html_form_manage.php" method="GET">
<input type="submit" value=" ก " />
</form>
ก F F ก ˁ ก F browser ʽ F
html_form_manage.php ก F Attribute actionhtml_form_manage.php ก F Attribute action
form
projetcsoft.biz F F ก
ก F F F ก submit form
F F F ก submit form F F F
<form action="textbox_input_manage.php"
method="get">
<input type="text" id="textbox1" name="textbox1" />
<input type="submit" value=" ก " /><input type="submit" value=" ก " />
</form>
ก F Tag input Attribute id name
projetcsoft.biz F F ก
ก F F F ก submit form
ก F F ก F F F F F
textbox_input_manage.php F
<?php
$textbox1=$_GET["textbox1"];
echo $textbox1;echo $textbox1;
?>
F ก ก F ก textbox F F
textbox_input_manage.php
projetcsoft.biz F F ก
ก F F F ก submit form
• ก F ก $textbox1=$_GET["textbox1"];
• F F tag input F textbox1 (ก
attribute name attribute id) ก F Fattribute name attribute id) ก F F
$textbox1
• ก F address bar F ก F F GET
F ก F F F tag form attribute action
textbox_input_manage.php?textbox1=PHP
• textbox_input_manage.php ก attribute action
form action="textbox_input_manage.php"
projetcsoft.biz F F ก
ก F F F ก submit form
textbox1 ก กAttribute name id<input type="text"
id="textbox1" name="textbox1" />
textbox_input_manage.php?textbox1=PHP
textbox1=PHP
=PHP กก F F F F F F “PHP” textbox1=PHP กก F F F F F F “PHP” textbox1
กF ก submit
projetcsoft.biz F F ก
ก F F F ก submit form
ก F F ก F F address bar F Attribute Form
method="get" ˈ method="post"
projetcsoft.biz F F ก
ก F F F ก submit form
ก F ก attribute Form ก
method="get" ˈ method="post" F
ˈ F F ก F ก
$textbox1=$_GET["textbox1"]; ˈ
$textbox1=$_POST["textbox1"]; F$textbox1=$_POST["textbox1"]; F
projetcsoft.biz F F ก
ก F F F ก submit form
projetcsoft.biz F F ก
ก Username Password
<form action="check_login.php" method="post">
<table><tr><td align="right">Username:</td>
<td><input type="text" id="username" name="username"
/></td>
</tr><tr><td align="right">Password:</td>
<td><td>
<input type="password" id="password" name="password" />
</td></tr><tr><td align="right"></td>
<td><input type="submit" value="Login" /></td>
</tr>
</table>
</form>
projetcsoft.biz F F ก
ก Username Password
F check_login.php
<?php
$username=$_POST["username"];
$password=$_POST["password"];
if(($username=="administrator")&&($password=="system"))
{{
echo "Login success";
}
else
{
echo "Login error ! <br />";
echo "<a href="login.php">Click to login agian</a>";
}
?>
projetcsoft.biz F F ก
ก Username Password 2
<?php if($_GET["err"]=="1"){echo "Login error !";} ?>
<form action="check_login2.php" method="post">
<table><tr><td align="right">Username:</td>
<td><input type="text" id="username" name="username"
/></td>
</tr><tr><td align="right">Password:</td>
<td>
<input type="password" id="password" name="password" />
</td></tr><tr><td align="right"></td>
<td><input type="submit" value="Login" /></td>
</tr>
</table>
</form>
projetcsoft.biz F F ก
ก Username Password 2
F check_login2.php
<?php
$username=$_POST["username"];
$password=$_POST["password"];
if(($username=="administrator")&&($password=="system"))
{{
echo "Login success";
}
else
{
echo "<script>location='login2.php?err=1'</script>";
exit();
}
?>
projetcsoft.biz F F ก
ก Username Password 2
ก F F F username password F ก F F ก
echo "<script>location='login2.php?err=1'</script>";
exit();
F browser F login2.php F F FF browser F login2.php F F F
?err=1 F
F ก F login2.php
<?php if($_GET["err"]=="1"){echo "Login error !";} ?>
F F Login error ! ก F F err=1
projetcsoft.biz F F ก
ก F F ก Tag select
<form method="post" action="select_input_manage.php">
<select id="number" name="number" >
<option value="">Please select umber</option>
<option value="1">One</option>
<option value="2">Two</option><option value="2">Two</option>
<option value="3">Three</option>
</select>
<input type="submit" value="OK" />
</form>
projetcsoft.biz F F ก
ก F F ก Tag select
ก F tag select attribute value
Attribute value F ก F F F F ก ก ก
F F F F ก ก Two F
$_POST["number"] F select_input_manage.php
F F ก ˈ 2 F value="2" ก TwoF F ก ˈ 2 F value="2" ก Two
<option value="2">Two</option>
projetcsoft.biz F F ก
ก F F ก Tag select
<?php
$num=$_POST["number"];
if($num=="")
{echo "You have not selected.";}
else if($num=="1")
{echo "You have selected One.";}{echo "You have selected One.";}
else if($num=="2")
{echo "You have selectedTwo.";}
else if($num=="3")
{echo "You have selectedTree.";}
?>
<br />
<a href="select_input_submit.php">Back to last page</a>
projetcsoft.biz F F ก
ก F F ก check box
<form method="post" action="checkbox_manage.php" >
Please select your programing langues skill.<br /><br />
<input type="checkbox" value="C++" id="cpp"
name="cpp" />C++
<input type="checkbox" value="Java" id="java"<input type="checkbox" value="Java" id="java"
name="java" />Java
<input type="checkbox" value="PHP" id="php"
name="php" />PHP
<input type="submit" value="OK" />
</form>
projetcsoft.biz F F ก
ก F F ก check box
F checkbox_manage.php
<?php
echo "You have ";
echo $_POST["cpp"]." ";echo $_POST["cpp"]." ";
echo $_POST["java"]." ";
echo $_POST["PHP"]." ";
echo " skill.";
?>
projetcsoft.biz F F ก
ก F F ก check box
ก code F F F F check box PHP F
F F ?
projetcsoft.biz F F ก
ก ก,
<form method="post" action="calculator_result.php">
<input type="text" id="num1" name="num1" size="3"
/>
<select id="opp" name="opp"><option
value="add">+</option><option value="sub">-value="add">+</option><option value="sub">-
</option></select>
<input type="text" id="num2" name="num2" size="3"
/>
<input type="submit" value="=" size="100"/>
</form>
projetcsoft.biz F F ก
ก ก,
<?php
$num1=$_POST["num1"];
$num2=$_POST["num2"];
if($_POST["opp"]=="add")
{$result=$num1+$num2;{$result=$num1+$num2;
echo $num1."+".$num2." = ".$result;}
else if($_POST["opp"]=="sub")
{$result=$num1-$num2;
echo $num1."-".$num2." = ".$result;
}
?>
projetcsoft.biz F F ก
ก ก, 2
<form method="post" action="calculator_result2.php">
<input type="text" id="num1" name="num1" /><br />
<input type="checkbox" value="add" id="op1"
name="op1" />+<br />
<input type="checkbox" value="sub" id="op2"<input type="checkbox" value="sub" id="op2"
name="op2" />-<br />
<input type="text" id="num2" name="num2" /><br />
<input type="submit" value="=" />
</form>
projetcsoft.biz F F ก
ก ก, 2
<?php
$num1=$_POST["num1"];
$num2=$_POST["num2"];
if($_POST["op1"]=="add")
{ $result=$num1+$num2;
echo $num1."+".$num2."=".$result."<br />";echo $num1."+".$num2."=".$result."<br />";
}
if($_POST["op2"]=="sub")
{ $result=$num1-$num2;
echo $num1."-".$num2."=".$result."<br />";
}
?>
projetcsoft.biz F F ก
ก F F F F ˈ F ก F
<form action="multiply.php" method="get">
<select id="num" name="num">
<option value="2">2</option>
<option value="3">3</option>
</select></select>
<input type="submit" value="show !" /></form>
<table>
projetcsoft.biz F F ก
ก F F F F ˈ F ก F
<table><?php
$num=$_GET["num"];
$count=1;
while($count<=12)
{ $result=$num*$count;
echo "<tr>";echo "<td>".$num."</td>";echo "<tr>";echo "<td>".$num."</td>";
echo "<td>X</td>";
echo "<td>".$count."=</td>";
echo "<td>".$result."</td>";echo "</tr>";
$count++;}
?></table>
source code F ก slice F F
projetcsoft.biz F F ก
Input file
Tag name input
Type file
F ก F tag form input file F tag form F F
attribute enctype="multipart/form-data" tag form F
FF
Tag input attribute id name F F F ก tag
input
projetcsoft.biz F F ก
Input file
<form action="upload_file.php" method="post"
enctype="multipart/form-data" >
upload file(.jpg)
<input type="file" name="file_1" id="file_1" />
<input type="submit" value="upload" /><input type="submit" value="upload" />
</form>
projetcsoft.biz F F ก
Input file
<?php
$file_1=$_FILES["file_1"];
$type = substr($file_1["name"], strpos($file_1["name"],"."),
strlen($file_1["name"])); $type =strtolower($type );
if($type!= ".jpg")
{echo "Please select .jpg file<br />";{echo "Please select .jpg file<br />";
echo "<a href="input_file.php" >Click to upload agian</a>";
} else{
copy($file_1["tmp_name"],"upload_img/upload_img.jpg");
echo "<img src="upload_img/upload_img.jpg" />";
}
?>
projetcsoft.biz F F ก
Input file
$file_1=$_FILES["file_1"];
ก F $file_1 F F input file attribute
id="file_1" name="file_1"
$file_1["name"] return F upload F
$type = substr($file_1["name"],$type = substr($file_1["name"],
strpos($file_1["name"],"."), strlen($file_1["name"])); ก
ก F upload ก F $type
projetcsoft.biz F F ก
Input file
$type F F F ก “.jpg” F F F F
F F link F F upload ก
F F F F F ก “.jpg”
copy($file_1["tmp_name"],"upload_img/upload_img.jpg");
F upload F F folder upload_imgF upload F F folder upload_img
F ˈ upload_img.jpg
projetcsoft.biz F F ก

Contenu connexe

Tendances

High-level Web Testing
High-level Web TestingHigh-level Web Testing
High-level Web Testing
petersergeant
 
Php Calling Operators
Php Calling OperatorsPhp Calling Operators
Php Calling Operators
mussawir20
 
Guía de uso de ISI WOK (ISI Web of Knowledge)
Guía de uso de ISI WOK (ISI Web of Knowledge)Guía de uso de ISI WOK (ISI Web of Knowledge)
Guía de uso de ISI WOK (ISI Web of Knowledge)
Marta Domínguez-Senra
 
Simple Blue Blog Template XML 的副本
Simple Blue Blog Template XML 的副本Simple Blue Blog Template XML 的副本
Simple Blue Blog Template XML 的副本
a5494535
 
Web осень 2012 лекция 7
Web осень 2012 лекция 7Web осень 2012 лекция 7
Web осень 2012 лекция 7
Technopark
 

Tendances (20)

Os Nixon
Os NixonOs Nixon
Os Nixon
 
PHP「参照渡しできるよ」(君の考えている参照渡しと同じとは言ってない)
PHP「参照渡しできるよ」(君の考えている参照渡しと同じとは言ってない)PHP「参照渡しできるよ」(君の考えている参照渡しと同じとは言ってない)
PHP「参照渡しできるよ」(君の考えている参照渡しと同じとは言ってない)
 
Laravel Poznań Meetup #2 - Wykorzystanie FormRequest w Laravelu
Laravel Poznań Meetup #2 - Wykorzystanie FormRequest w LaraveluLaravel Poznań Meetup #2 - Wykorzystanie FormRequest w Laravelu
Laravel Poznań Meetup #2 - Wykorzystanie FormRequest w Laravelu
 
Php Rss
Php RssPhp Rss
Php Rss
 
High-level Web Testing
High-level Web TestingHigh-level Web Testing
High-level Web Testing
 
Php Calling Operators
Php Calling OperatorsPhp Calling Operators
Php Calling Operators
 
Guía de uso de ISI WOK (ISI Web of Knowledge)
Guía de uso de ISI WOK (ISI Web of Knowledge)Guía de uso de ISI WOK (ISI Web of Knowledge)
Guía de uso de ISI WOK (ISI Web of Knowledge)
 
Refactoring using Codeception
Refactoring using CodeceptionRefactoring using Codeception
Refactoring using Codeception
 
Simple Blue Blog Template XML 的副本
Simple Blue Blog Template XML 的副本Simple Blue Blog Template XML 的副本
Simple Blue Blog Template XML 的副本
 
Can WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noCan WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.no
 
Cloud Entwicklung mit Apex
Cloud Entwicklung mit ApexCloud Entwicklung mit Apex
Cloud Entwicklung mit Apex
 
TDC2016SP - Trilha Developing for Business
TDC2016SP - Trilha Developing for BusinessTDC2016SP - Trilha Developing for Business
TDC2016SP - Trilha Developing for Business
 
Developing for Business
Developing for BusinessDeveloping for Business
Developing for Business
 
Developing applications for performance
Developing applications for performanceDeveloping applications for performance
Developing applications for performance
 
FQL Overview
FQL OverviewFQL Overview
FQL Overview
 
Using an ARLA Agent
Using an ARLA AgentUsing an ARLA Agent
Using an ARLA Agent
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
symfony & jQuery (PUG)
symfony & jQuery (PUG)symfony & jQuery (PUG)
symfony & jQuery (PUG)
 
Rails view chapte 5 - form
Rails view   chapte 5 - formRails view   chapte 5 - form
Rails view chapte 5 - form
 
Web осень 2012 лекция 7
Web осень 2012 лекция 7Web осень 2012 лекция 7
Web осень 2012 лекция 7
 

Similaire à Session6

Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2
RORLAB
 

Similaire à Session6 (20)

5.1 html lec 5
5.1 html lec 55.1 html lec 5
5.1 html lec 5
 
Zencoding cheatsheet, ayuda Memoria
Zencoding cheatsheet, ayuda MemoriaZencoding cheatsheet, ayuda Memoria
Zencoding cheatsheet, ayuda Memoria
 
Zen Coding Cheat Sheet
Zen Coding Cheat SheetZen Coding Cheat Sheet
Zen Coding Cheat Sheet
 
Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2
 
HTML5 workshop, forms
HTML5 workshop, formsHTML5 workshop, forms
HTML5 workshop, forms
 
Bad Form @ Form, Function & Class 2016
Bad Form @ Form, Function & Class 2016Bad Form @ Form, Function & Class 2016
Bad Form @ Form, Function & Class 2016
 
Web I - 04 - Forms
Web I - 04 - FormsWeb I - 04 - Forms
Web I - 04 - Forms
 
Alfresco Forms Service Deep Dive
Alfresco Forms Service Deep DiveAlfresco Forms Service Deep Dive
Alfresco Forms Service Deep Dive
 
Facebook Development with Zend Framework
Facebook Development with Zend FrameworkFacebook Development with Zend Framework
Facebook Development with Zend Framework
 
4.1 html lec 4
4.1 html lec 44.1 html lec 4
4.1 html lec 4
 
04 Html Form Get Post Login System
04 Html Form Get Post Login System04 Html Form Get Post Login System
04 Html Form Get Post Login System
 
05 File Handling Upload Mysql
05 File Handling Upload Mysql05 File Handling Upload Mysql
05 File Handling Upload Mysql
 
Cmsc 100 (web forms)
Cmsc 100 (web forms)Cmsc 100 (web forms)
Cmsc 100 (web forms)
 
HSC INFORMATION TECHNOLOGY CHAPTER 1 ADVANCED WEB DESIGNING PART III.pdf
HSC INFORMATION TECHNOLOGY CHAPTER 1 ADVANCED WEB DESIGNING PART III.pdfHSC INFORMATION TECHNOLOGY CHAPTER 1 ADVANCED WEB DESIGNING PART III.pdf
HSC INFORMATION TECHNOLOGY CHAPTER 1 ADVANCED WEB DESIGNING PART III.pdf
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
 
phptut2
phptut2phptut2
phptut2
 
phptut2
phptut2phptut2
phptut2
 
phptut2
phptut2phptut2
phptut2
 
phptut2
phptut2phptut2
phptut2
 
HTML::FormHandler
HTML::FormHandlerHTML::FormHandler
HTML::FormHandler
 

Dernier

Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 

Dernier (20)

WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 

Session6

  • 1. ก F ก F PHP HTML Form ก F ก F PHP projetcsoft.biz F F ก
  • 2. Tag Form Tag input F F F tag form Tag form ˈ F F F F F F F tag input F .php.php ก F F F ก F F .php F Form .PHP file projetcsoft.biz F F ก
  • 3. Tag Form Attribute ˈ F tag form method, action Attribute action F ก F F form file file Attribute method F ก F F F form ˈ GET ( F address bar F index.php?id=1&name=John )( F address bar F index.php?id=1&name=John ) POST ( F F address bar) Tag form ˈ F tag <input type=“submit” /> projetcsoft.biz F F ก
  • 4. Tag Form <form action= F F ก .php method=GET POST> …… …… </form></form> projetcsoft.biz F F ก
  • 5. Tag input type submit Tag input Attribute type ˈ submit ˈ ˁ ก Attribute value F ˁ Tag input type submit F F F tag form F F F ก ˁ submit form F browser ʽ F ก F Attribute action formก F Attribute action form projetcsoft.biz F F ก
  • 6. Tag Form <form action="html_form_manage.php" method="GET"> <input type="submit" value=" ก " /> </form> ก F F ก ˁ ก F browser ʽ F html_form_manage.php ก F Attribute actionhtml_form_manage.php ก F Attribute action form projetcsoft.biz F F ก
  • 7. ก F F F ก submit form F F F ก submit form F F F <form action="textbox_input_manage.php" method="get"> <input type="text" id="textbox1" name="textbox1" /> <input type="submit" value=" ก " /><input type="submit" value=" ก " /> </form> ก F Tag input Attribute id name projetcsoft.biz F F ก
  • 8. ก F F F ก submit form ก F F ก F F F F F textbox_input_manage.php F <?php $textbox1=$_GET["textbox1"]; echo $textbox1;echo $textbox1; ?> F ก ก F ก textbox F F textbox_input_manage.php projetcsoft.biz F F ก
  • 9. ก F F F ก submit form • ก F ก $textbox1=$_GET["textbox1"]; • F F tag input F textbox1 (ก attribute name attribute id) ก F Fattribute name attribute id) ก F F $textbox1 • ก F address bar F ก F F GET F ก F F F tag form attribute action textbox_input_manage.php?textbox1=PHP • textbox_input_manage.php ก attribute action form action="textbox_input_manage.php" projetcsoft.biz F F ก
  • 10. ก F F F ก submit form textbox1 ก กAttribute name id<input type="text" id="textbox1" name="textbox1" /> textbox_input_manage.php?textbox1=PHP textbox1=PHP =PHP กก F F F F F F “PHP” textbox1=PHP กก F F F F F F “PHP” textbox1 กF ก submit projetcsoft.biz F F ก
  • 11. ก F F F ก submit form ก F F ก F F address bar F Attribute Form method="get" ˈ method="post" projetcsoft.biz F F ก
  • 12. ก F F F ก submit form ก F ก attribute Form ก method="get" ˈ method="post" F ˈ F F ก F ก $textbox1=$_GET["textbox1"]; ˈ $textbox1=$_POST["textbox1"]; F$textbox1=$_POST["textbox1"]; F projetcsoft.biz F F ก
  • 13. ก F F F ก submit form projetcsoft.biz F F ก
  • 14. ก Username Password <form action="check_login.php" method="post"> <table><tr><td align="right">Username:</td> <td><input type="text" id="username" name="username" /></td> </tr><tr><td align="right">Password:</td> <td><td> <input type="password" id="password" name="password" /> </td></tr><tr><td align="right"></td> <td><input type="submit" value="Login" /></td> </tr> </table> </form> projetcsoft.biz F F ก
  • 15. ก Username Password F check_login.php <?php $username=$_POST["username"]; $password=$_POST["password"]; if(($username=="administrator")&&($password=="system")) {{ echo "Login success"; } else { echo "Login error ! <br />"; echo "<a href="login.php">Click to login agian</a>"; } ?> projetcsoft.biz F F ก
  • 16. ก Username Password 2 <?php if($_GET["err"]=="1"){echo "Login error !";} ?> <form action="check_login2.php" method="post"> <table><tr><td align="right">Username:</td> <td><input type="text" id="username" name="username" /></td> </tr><tr><td align="right">Password:</td> <td> <input type="password" id="password" name="password" /> </td></tr><tr><td align="right"></td> <td><input type="submit" value="Login" /></td> </tr> </table> </form> projetcsoft.biz F F ก
  • 17. ก Username Password 2 F check_login2.php <?php $username=$_POST["username"]; $password=$_POST["password"]; if(($username=="administrator")&&($password=="system")) {{ echo "Login success"; } else { echo "<script>location='login2.php?err=1'</script>"; exit(); } ?> projetcsoft.biz F F ก
  • 18. ก Username Password 2 ก F F F username password F ก F F ก echo "<script>location='login2.php?err=1'</script>"; exit(); F browser F login2.php F F FF browser F login2.php F F F ?err=1 F F ก F login2.php <?php if($_GET["err"]=="1"){echo "Login error !";} ?> F F Login error ! ก F F err=1 projetcsoft.biz F F ก
  • 19. ก F F ก Tag select <form method="post" action="select_input_manage.php"> <select id="number" name="number" > <option value="">Please select umber</option> <option value="1">One</option> <option value="2">Two</option><option value="2">Two</option> <option value="3">Three</option> </select> <input type="submit" value="OK" /> </form> projetcsoft.biz F F ก
  • 20. ก F F ก Tag select ก F tag select attribute value Attribute value F ก F F F F ก ก ก F F F F ก ก Two F $_POST["number"] F select_input_manage.php F F ก ˈ 2 F value="2" ก TwoF F ก ˈ 2 F value="2" ก Two <option value="2">Two</option> projetcsoft.biz F F ก
  • 21. ก F F ก Tag select <?php $num=$_POST["number"]; if($num=="") {echo "You have not selected.";} else if($num=="1") {echo "You have selected One.";}{echo "You have selected One.";} else if($num=="2") {echo "You have selectedTwo.";} else if($num=="3") {echo "You have selectedTree.";} ?> <br /> <a href="select_input_submit.php">Back to last page</a> projetcsoft.biz F F ก
  • 22. ก F F ก check box <form method="post" action="checkbox_manage.php" > Please select your programing langues skill.<br /><br /> <input type="checkbox" value="C++" id="cpp" name="cpp" />C++ <input type="checkbox" value="Java" id="java"<input type="checkbox" value="Java" id="java" name="java" />Java <input type="checkbox" value="PHP" id="php" name="php" />PHP <input type="submit" value="OK" /> </form> projetcsoft.biz F F ก
  • 23. ก F F ก check box F checkbox_manage.php <?php echo "You have "; echo $_POST["cpp"]." ";echo $_POST["cpp"]." "; echo $_POST["java"]." "; echo $_POST["PHP"]." "; echo " skill."; ?> projetcsoft.biz F F ก
  • 24. ก F F ก check box ก code F F F F check box PHP F F F ? projetcsoft.biz F F ก
  • 25. ก ก, <form method="post" action="calculator_result.php"> <input type="text" id="num1" name="num1" size="3" /> <select id="opp" name="opp"><option value="add">+</option><option value="sub">-value="add">+</option><option value="sub">- </option></select> <input type="text" id="num2" name="num2" size="3" /> <input type="submit" value="=" size="100"/> </form> projetcsoft.biz F F ก
  • 26. ก ก, <?php $num1=$_POST["num1"]; $num2=$_POST["num2"]; if($_POST["opp"]=="add") {$result=$num1+$num2;{$result=$num1+$num2; echo $num1."+".$num2." = ".$result;} else if($_POST["opp"]=="sub") {$result=$num1-$num2; echo $num1."-".$num2." = ".$result; } ?> projetcsoft.biz F F ก
  • 27. ก ก, 2 <form method="post" action="calculator_result2.php"> <input type="text" id="num1" name="num1" /><br /> <input type="checkbox" value="add" id="op1" name="op1" />+<br /> <input type="checkbox" value="sub" id="op2"<input type="checkbox" value="sub" id="op2" name="op2" />-<br /> <input type="text" id="num2" name="num2" /><br /> <input type="submit" value="=" /> </form> projetcsoft.biz F F ก
  • 28. ก ก, 2 <?php $num1=$_POST["num1"]; $num2=$_POST["num2"]; if($_POST["op1"]=="add") { $result=$num1+$num2; echo $num1."+".$num2."=".$result."<br />";echo $num1."+".$num2."=".$result."<br />"; } if($_POST["op2"]=="sub") { $result=$num1-$num2; echo $num1."-".$num2."=".$result."<br />"; } ?> projetcsoft.biz F F ก
  • 29. ก F F F F ˈ F ก F <form action="multiply.php" method="get"> <select id="num" name="num"> <option value="2">2</option> <option value="3">3</option> </select></select> <input type="submit" value="show !" /></form> <table> projetcsoft.biz F F ก
  • 30. ก F F F F ˈ F ก F <table><?php $num=$_GET["num"]; $count=1; while($count<=12) { $result=$num*$count; echo "<tr>";echo "<td>".$num."</td>";echo "<tr>";echo "<td>".$num."</td>"; echo "<td>X</td>"; echo "<td>".$count."=</td>"; echo "<td>".$result."</td>";echo "</tr>"; $count++;} ?></table> source code F ก slice F F projetcsoft.biz F F ก
  • 31. Input file Tag name input Type file F ก F tag form input file F tag form F F attribute enctype="multipart/form-data" tag form F FF Tag input attribute id name F F F ก tag input projetcsoft.biz F F ก
  • 32. Input file <form action="upload_file.php" method="post" enctype="multipart/form-data" > upload file(.jpg) <input type="file" name="file_1" id="file_1" /> <input type="submit" value="upload" /><input type="submit" value="upload" /> </form> projetcsoft.biz F F ก
  • 33. Input file <?php $file_1=$_FILES["file_1"]; $type = substr($file_1["name"], strpos($file_1["name"],"."), strlen($file_1["name"])); $type =strtolower($type ); if($type!= ".jpg") {echo "Please select .jpg file<br />";{echo "Please select .jpg file<br />"; echo "<a href="input_file.php" >Click to upload agian</a>"; } else{ copy($file_1["tmp_name"],"upload_img/upload_img.jpg"); echo "<img src="upload_img/upload_img.jpg" />"; } ?> projetcsoft.biz F F ก
  • 34. Input file $file_1=$_FILES["file_1"]; ก F $file_1 F F input file attribute id="file_1" name="file_1" $file_1["name"] return F upload F $type = substr($file_1["name"],$type = substr($file_1["name"], strpos($file_1["name"],"."), strlen($file_1["name"])); ก ก F upload ก F $type projetcsoft.biz F F ก
  • 35. Input file $type F F F ก “.jpg” F F F F F F link F F upload ก F F F F F ก “.jpg” copy($file_1["tmp_name"],"upload_img/upload_img.jpg"); F upload F F folder upload_imgF upload F F folder upload_img F ˈ upload_img.jpg projetcsoft.biz F F ก