SlideShare a Scribd company logo
1 of 2
PHP

PHP File Upload:
                With PHP, it is possible to upload files to the server.
<html>
<body>
<form action="upload_file.php" method="post"
enctype="multipart/form­data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html> 
         The enctype attribute of the <form> tag specifies which content-type to use when
submitting the form. "multipart/form-data" is used when a form requires binary
data, like the contents of a file, to be uploaded

    The type="file" attribute of the <input> tag specifies that the input should
be processed as a file. For example, when viewed in a browser, there will be a
browse-button next to the input field

Cookies:
            A cookie is often used to identify a user. A cookie is a small file that the server
embeds on the user's computer. Each time the same computer requests a page
with a browser, it will send the cookie too. With PHP, you can both create and
retrieve cookie values.

          The setcookie() function is used to set a cookie.

          Note: The setcookie() function must appear BEFORE the <html> tag.

Syntax : 
         setcookie(name, value, expire, path, domain);
                                                 
Example 
     In the example below, we will create a cookie named "user" and assign the value
"Alex Porter" to it. We also specify that the cookie should expire after one hour.
 
?php
setcookie("user", "Alex Porter", time()+3600);
?>
<html>
PHP Sessions
          A PHP session variable is used to store information about, or change settings
for a user session. Session variables hold information about one single user,
and are available to all pages in one application.

          A PHP session solves this problem by allowing you to store user information on
the server for later use (i.e. username, shopping items, etc).

         However, session information is temporary and will be deleted after the user has
left the website. If you need a permanent storage you may want to store the
data in a database.

Sessions work by creating a unique id (UID) for each visitor and store variables based
on this UID. The UID is either stored in a cookie or is propagated in the URL.

Starting a PHP Session
         <?php session_start(); ?>
         <html>
         <body>

         </body>
         </html> 

PHP error_log() Function
                          The error_log() function sends an error to the server error log, a file or a
remote destination.

                          This funtion returns TRUE on success, or FALSE on failure.
Syntax:
            error_log(error,type,destination,headers) 
PHP parse_ini_file() Function
        The parse_ini_file() function parses a configuration (ini) file and 
returns the settings in it in an array.

Syntax:
             parse_ini_file(file,process_sections) 
 
                 Parameters             Descriptions

               file                  Required. Specifies the ini file to check

               Process section       Optional. If set to TRUE, it returns is a 
                                     multidimensional array with section names and
                                     settings included. Default is FALSE

More Related Content

What's hot

Stefaan Ponnet, Fusebox
Stefaan Ponnet, FuseboxStefaan Ponnet, Fusebox
Stefaan Ponnet, Fusebox
nascomgenk
 
Creating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemCreating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login System
Azharul Haque Shohan
 
Setting up ftp for mp
Setting up ftp for mpSetting up ftp for mp
Setting up ftp for mp
hccit
 

What's hot (20)

Robots and-sitemap - Version 1.0.1
Robots and-sitemap - Version 1.0.1Robots and-sitemap - Version 1.0.1
Robots and-sitemap - Version 1.0.1
 
Mixing Identity server, AAD, ASP .NET Identity
Mixing Identity server, AAD, ASP .NET IdentityMixing Identity server, AAD, ASP .NET Identity
Mixing Identity server, AAD, ASP .NET Identity
 
Drag and drop file upload with Dropzone in CodeIgniter
Drag and drop file upload with Dropzone in CodeIgniterDrag and drop file upload with Dropzone in CodeIgniter
Drag and drop file upload with Dropzone in CodeIgniter
 
php $_GET / $_POST / $_SESSION
php  $_GET / $_POST / $_SESSIONphp  $_GET / $_POST / $_SESSION
php $_GET / $_POST / $_SESSION
 
Introduction to Plugin Programming, WordCamp Miami 2011
Introduction to Plugin Programming, WordCamp Miami 2011Introduction to Plugin Programming, WordCamp Miami 2011
Introduction to Plugin Programming, WordCamp Miami 2011
 
Stefaan Ponnet, Fusebox
Stefaan Ponnet, FuseboxStefaan Ponnet, Fusebox
Stefaan Ponnet, Fusebox
 
New: Two Methods of Installing Drupal on Windows XP with XAMPP
New: Two Methods of Installing Drupal on Windows XP with XAMPPNew: Two Methods of Installing Drupal on Windows XP with XAMPP
New: Two Methods of Installing Drupal on Windows XP with XAMPP
 
Creating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemCreating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login System
 
An introduction to consuming remote APIs with Drupal 7
An introduction to consuming remote APIs with Drupal 7An introduction to consuming remote APIs with Drupal 7
An introduction to consuming remote APIs with Drupal 7
 
Drupal 6 in a nutshell
Drupal 6 in a nutshellDrupal 6 in a nutshell
Drupal 6 in a nutshell
 
Php - Getting good with session
Php - Getting good with sessionPhp - Getting good with session
Php - Getting good with session
 
Nj 09 T2 David Frischknecht
Nj 09 T2 David FrischknechtNj 09 T2 David Frischknecht
Nj 09 T2 David Frischknecht
 
Profile
ProfileProfile
Profile
 
Having fun with code igniter
Having fun with code igniterHaving fun with code igniter
Having fun with code igniter
 
Session php
Session phpSession php
Session php
 
So You're the New SharePoint Administrator
So You're the New SharePoint AdministratorSo You're the New SharePoint Administrator
So You're the New SharePoint Administrator
 
Understanding Box UI Elements
Understanding Box UI ElementsUnderstanding Box UI Elements
Understanding Box UI Elements
 
File upload in oracle adf mobile
File upload in oracle adf mobileFile upload in oracle adf mobile
File upload in oracle adf mobile
 
Setting up ftp for mp
Setting up ftp for mpSetting up ftp for mp
Setting up ftp for mp
 
Building a Backend with Flask
Building a Backend with FlaskBuilding a Backend with Flask
Building a Backend with Flask
 

Viewers also liked (20)

2.5.3 dr tracy castelino
2.5.3 dr tracy castelino2.5.3 dr tracy castelino
2.5.3 dr tracy castelino
 
Seo optimizacija
Seo optimizacija Seo optimizacija
Seo optimizacija
 
Bicentenario 2010 franzante
Bicentenario 2010 franzanteBicentenario 2010 franzante
Bicentenario 2010 franzante
 
Nokia lumia 900
Nokia lumia 900Nokia lumia 900
Nokia lumia 900
 
Project proposal final
Project proposal finalProject proposal final
Project proposal final
 
Ativ3.1marialuiza
Ativ3.1marialuizaAtiv3.1marialuiza
Ativ3.1marialuiza
 
Portifólio
PortifólioPortifólio
Portifólio
 
Team a litcricles needreferencesfrommarsh
Team a litcricles needreferencesfrommarshTeam a litcricles needreferencesfrommarsh
Team a litcricles needreferencesfrommarsh
 
Psicologia Do Desenvolvimento Slides
Psicologia Do Desenvolvimento SlidesPsicologia Do Desenvolvimento Slides
Psicologia Do Desenvolvimento Slides
 
Marte
MarteMarte
Marte
 
1
11
1
 
App Concept Design Schedule
App Concept Design ScheduleApp Concept Design Schedule
App Concept Design Schedule
 
El memorándum
El memorándumEl memorándum
El memorándum
 
Local newspapers
Local newspapersLocal newspapers
Local newspapers
 
Iluminacion nocturna
Iluminacion nocturnaIluminacion nocturna
Iluminacion nocturna
 
~$40 bauer rd
~$40 bauer rd~$40 bauer rd
~$40 bauer rd
 
Ngo cfa deo gratias booklet
Ngo cfa deo gratias bookletNgo cfa deo gratias booklet
Ngo cfa deo gratias booklet
 
ExplicaçõEs Aos Nossos Queridos UsuáRios/cloniasespirituais
ExplicaçõEs Aos Nossos Queridos UsuáRios/cloniasespirituaisExplicaçõEs Aos Nossos Queridos UsuáRios/cloniasespirituais
ExplicaçõEs Aos Nossos Queridos UsuáRios/cloniasespirituais
 
Leaf Medium
Leaf MediumLeaf Medium
Leaf Medium
 
Postulantes comunicación 2010
Postulantes comunicación 2010Postulantes comunicación 2010
Postulantes comunicación 2010
 

Similar to Php BASIC

LAMP security practices
LAMP security practicesLAMP security practices
LAMP security practices
Amit Kejriwal
 
Php File Upload
Php File UploadPhp File Upload
Php File Upload
saeel005
 

Similar to Php BASIC (20)

Spsl v unit - final
Spsl v unit - finalSpsl v unit - final
Spsl v unit - final
 
Php
PhpPhp
Php
 
Ph
PhPh
Ph
 
Php advance
Php advancePhp advance
Php advance
 
Restap ito uploadfilessharepoint
Restap ito uploadfilessharepointRestap ito uploadfilessharepoint
Restap ito uploadfilessharepoint
 
RESTAPI_SPHOSTED_APP
RESTAPI_SPHOSTED_APPRESTAPI_SPHOSTED_APP
RESTAPI_SPHOSTED_APP
 
PHP SESSIONS & COOKIE.pptx
PHP SESSIONS & COOKIE.pptxPHP SESSIONS & COOKIE.pptx
PHP SESSIONS & COOKIE.pptx
 
Class 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingClass 6 - PHP Web Programming
Class 6 - PHP Web Programming
 
Parameter Passing & Session Tracking in PHP
Parameter Passing & Session Tracking in PHPParameter Passing & Session Tracking in PHP
Parameter Passing & Session Tracking in PHP
 
Chapter 08 php advance
Chapter 08   php advanceChapter 08   php advance
Chapter 08 php advance
 
18.register login
18.register login18.register login
18.register login
 
PHP 2
PHP 2PHP 2
PHP 2
 
LAMP security practices
LAMP security practicesLAMP security practices
LAMP security practices
 
PHP Hypertext Preprocessor
PHP Hypertext PreprocessorPHP Hypertext Preprocessor
PHP Hypertext Preprocessor
 
lecture 13.pptx
lecture 13.pptxlecture 13.pptx
lecture 13.pptx
 
Introduction to php web programming - get and post
Introduction to php  web programming - get and postIntroduction to php  web programming - get and post
Introduction to php web programming - get and post
 
CGI by rj
CGI by rjCGI by rj
CGI by rj
 
lecture 11.pptx
lecture 11.pptxlecture 11.pptx
lecture 11.pptx
 
Php File Upload
Php File UploadPhp File Upload
Php File Upload
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.pptLecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 

Php BASIC

  • 1. PHP PHP File Upload:  With PHP, it is possible to upload files to the server. <html> <body> <form action="upload_file.php" method="post" enctype="multipart/form­data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html>           The enctype attribute of the <form> tag specifies which content-type to use when submitting the form. "multipart/form-data" is used when a form requires binary data, like the contents of a file, to be uploaded The type="file" attribute of the <input> tag specifies that the input should be processed as a file. For example, when viewed in a browser, there will be a browse-button next to the input field Cookies:             A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values.           The setcookie() function is used to set a cookie.           Note: The setcookie() function must appear BEFORE the <html> tag. Syntax :           setcookie(name, value, expire, path, domain);   Example       In the example below, we will create a cookie named "user" and assign the value "Alex Porter" to it. We also specify that the cookie should expire after one hour.   ?php setcookie("user", "Alex Porter", time()+3600); ?> <html>
  • 2. PHP Sessions           A PHP session variable is used to store information about, or change settings for a user session. Session variables hold information about one single user, and are available to all pages in one application.           A PHP session solves this problem by allowing you to store user information on the server for later use (i.e. username, shopping items, etc).          However, session information is temporary and will be deleted after the user has left the website. If you need a permanent storage you may want to store the data in a database. Sessions work by creating a unique id (UID) for each visitor and store variables based on this UID. The UID is either stored in a cookie or is propagated in the URL. Starting a PHP Session          <?php session_start(); ?>          <html>          <body>          </body>          </html>  PHP error_log() Function                           The error_log() function sends an error to the server error log, a file or a remote destination.                           This funtion returns TRUE on success, or FALSE on failure. Syntax:             error_log(error,type,destination,headers)  PHP parse_ini_file() Function         The parse_ini_file() function parses a configuration (ini) file and  returns the settings in it in an array. Syntax:              parse_ini_file(file,process_sections)    Parameters Descriptions file Required. Specifies the ini file to check Process section Optional. If set to TRUE, it returns is a  multidimensional array with section names and settings included. Default is FALSE