PHP Language Professional Home Page Prominent Free n









































![Session ��� Cookie <? php echo $HTTP_COOKIE_VARS['test. Cookie']; ? > test. php Session ��� Cookie <? php echo $HTTP_COOKIE_VARS['test. Cookie']; ? > test. php](https://slidetodoc.com/presentation_image_h/0cbe7f92e1db82c2878c41682eb8642e/image-42.jpg)


![Session ��� Cookie <? php echo $HTTP_COOKIE_VARS['test. Cookie']; ? > test. php Session ��� Cookie <? php echo $HTTP_COOKIE_VARS['test. Cookie']; ? > test. php](https://slidetodoc.com/presentation_image_h/0cbe7f92e1db82c2878c41682eb8642e/image-45.jpg)






- Slides: 51
PHP Language Professional Home Page
Prominent Free n Speed n Open Source n Crossable Platform n Database Access n Protocol Support n Library n Flexible n Easy n
HTML Clients Browser Server PHP Libraries Interpreter Other Database
�������� PHP n n ��� Appserv ���������� �Web Server �� Appserv ����� Application ���� 1. PHP 2. MYSQL 3. Apache Edit. Plus 2. 10 c
PHP Scripts For Development Application Powered by Atthaphorn
<? php ������ PHP Engine echo phpinfo(); ? >
<? php $number=5; if($number==5) { echo "Number is 5"; } ? > ���� ����
<? php $number=5; if($number==6) { echo "Number is 5"; }else{ echo "Oh!!! NO"; } ? > ���� ����
<? php $name="toon"; if($name=="atthaphorn"){ echo "Hello Atthaphorn"; }elseif($name=="vinai"){ echo "Hello vinai"; }else{ echo "Good Bye"; } ? > ���� �� �����
<? php $name="atthaphorn"; switch($name){ case "atthaphorn": echo "คณโอ "; break; case "vinai" : echo "คณหม "; break; default : echo "ไครกไมทราบครบ "; break; } ? > ������� �
������� �� ตองสรางหนาสงคาจาก page html กอนสงไปยง page php ประมวลผล <html><head><title>����� php </title></head> <body> <form action="test. php" method="post"> ������������� <input type="text" name="textname"> <input type="submit" value="����� "> </form> </body> </html> index. html
����� Function n Function ������ return ����� function <? php function test($number){ $i=5; echo $i+$number; } test(5); ? >
����� Function n Function ���� return ����� function <? php function test($number){ $i=5; return $i+$number; } echo test(5); ? >
Session ��� Cookie session_start() �������� session ������ n session_register() ������������� session <html> n <head><title>Session </title></head> <body> <? php session_start(); $name="������ "; session_register("name"); ? > <a href="test. php">������� session </a> </body> </html> index. php
Session ��� Cookie <? php session_start(); echo $name; ? > test. php
Session ��� Cookie session_destroy() ������������� session �������������������� <html> <head><title>Session </title></head> n session_unregister() <body> ������������� <? php index. php n session_start(); $first. Name="������ "; $last. Name=“����� ”; session_register(“first. Name“, ”last. Name”); ? > <a href="test. php">������� session_unregister</a> </body> </html>
Session ��� Cookie <? php session_start(); session_unregister("first. Name"); echo $firs. Name. " "; echo $last. Name; ? > test. php
Session ��� Cookie n setcookie() ������� Cookie <html> <head><title>Session </title></head> <body> <? php $name_cookie="test. Cookie"; $cookie_value="1234"; setcookie($name_cookie, $cookie_value, time()+60); echo "Cookie ���������� "; ? > <a href="test. php">����� Cookie</a> </body> </html> index. php
Session ��� Cookie <? php echo $HTTP_COOKIE_VARS['test. Cookie']; ? > test. php
Session ��� Cookie ������ header already ������ Code <? php ������ n ob_start(); $name_cookie="test. Cookie"; $cookie_value="1234"; setcookie($name_cookie, $cookie_value, time()+60); echo "Cookie ���������� "; echo "<a href="test. php">����� Cookie</a>"; ob_end_flush(); ? > index. php
Session ��� Cookie <? php echo $HTTP_COOKIE_VARS['test. Cookie']; ? > test. php
����� My. SQL n n n ���������� PHP Myadmin ������� user = attapon password = 1234 ������� database = test table = table 1 �� 3 fields id, f_name, l_name
n n My. SQL(��������� SQL ����� ) mysql_query() SQL Server ������ mysql_query(������ SQL( insert into ������ (field 1, field 2) values (value 1, value 2) ��������� <? php mysql_connect("localhost", "attapon", "1234") or die ("����� "); $sql="insert into table 1 (id, f_name, l_name) values ('1', '������ ', '����� ')"; mysql_db_query("test", $sql); mysql_close(); ? >
My. SQL(������� n Select * from ���� table ����� ) Select * from ���� table order by ����� desc ������ <? php n Select ����� 1, ����� 2, . . from ���� table mysql_connect("localhost", "attapon", "1234") or die ("����� "); ��������� $sql="select f_name from table 1"; n $data=mysql_db_query("test", $sql); $row=mysql_num_rows($data); for($i=0; $i<=$row; $i++){ $show=mysql_fetch_array($data); echo $show[f_name]. " "; } mysql_close(); ? >
My. SQL(����� n update ���� �� ���� set ����� =������ , . . where �� ) ������ �� <? php mysql_connect("localhost", "attapon", "1234") or die ("����� "); $sql="update table 1 set f_name='atthaphorn' where f_name='������ '"; $data=mysql_db_query("test", $sql); mysql_close(); ? >
������ My. SQL(������� ) <? php mysql_connect("localhost", "attapon", "1234") or die ("����� "); $sql="delete from table 1 where f_name='atthaphorn'"; $data=mysql_db_query("test", $sql); mysql_close(); ? >