SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
PRACTICAL PHP
 BY EXAMPLE

 Jan Leth-Kjaer
Scope and subjects
• This is not a PHP upcode class.
• This is not a Zend class.
• This is not an Power specific class.
• This is not about installation of
  Apache.
• This is not about work management
  of Pase, PHP or related areas.
• This is not a PHP security class.
So what is it then?
• I presume you all know some type of
  programming and SQL.
• I presume you know HTML at some level.
• I presume you can or know a bit of PHP or
  likewise programming languages.
• We will running through a number of practial
  PHP examples and see the frontend as well as
  the backend = code.
Data management

•   MySQL – the database.
•   Retrieve some data.
•   Show the data.
•   Give user functionality to enter/update data.
•   Update the data in database.
Data management – go get it

<?php
session_start();
require("access.php"); // Variabler til mysql hentes
$resultat = mysql_query("SELECT * FROM customer WHERE customernumber = '$number'");
while ($row = mysql_fetch_array($resultat)) {
$CompanyName = $row['CompanyName'];
$Name = $row['Name'];
$email = $row['email'];
$Address1 = $row['Address1'];
$Address2 = $row['Address2'];
....
?>

......

<form action='index.php?page1=CustomerValidate.php method='post' enctype='multipart/form-data'>
....

<tr>
<td width="193"><font face="Verdana" size="2"><b>Companyname:<font color="#FF0000">*</font></b></font></td>
<td colspan="2"><input type="text" name="T1" size="50" tabindex="1" value="<?php echo $CompanyName ; ?>" ></td>
</tr>
Data management – validate/update

$CompanyName = $_POST[‘CompanyName '];
.....

// Validate...

if(empty( $CompanyName ) ) {
      $error1 = '<br> Companyname is empty ';
      }

....

if (preg_match("/^([w|.|-|_]+)@([w||-|_]+).([w|.|-|_]+)$/i", $email-address)) {

 } else {
   $error4 = "<br> Email is not correctt!";
 }

....
Echo $error1 . $error4;
.....

mysql_query("UPDATE Customer SET CompanyName = '$CompanyName '..... Where....
File management

• File management on server.
<table border="0" width="50%" cellspacing="10" cellpadding="20">
<?php
$path = « foldername";
  // Open the folder
  $dir_handle = @opendir($path) or die("Unable to open $path");
  // Loop through the files
  while ($file = readdir($dir_handle)) {
  if($file == "." || $file == ".." || substr($file, 0, 10) != 'Nyhedsbrev') continue;
        $aar = substr($file, 11, 4);
        $month_number = substr($file, 16, 2);
        $month_name = date( 'F', mktime(0, 0, 0, $month_number) );
        echo "<tr><td width='32' align='left' valign='top'><font face='Verdana' size='2'>";
        echo "<font face='Verdana' size='2'>" . $aar . "</td><td><font face='Verdana' size='2'>" . $month_name . "</td><td>";
        echo "<font face='Verdana' size='2'><a href='/ foldername /$file'>$file</a></td></tr>";
  }
  // Close
  closedir($dir_handle);
?>
</table>
PDF creation

• PHP plugin.
<?php
require('fpdf.php');
                                                                                                http://www.fpdf.org
// Get some data – to use..
$resultat1 = mysql_query("SELECT * from meetings where active=‘NEXT'") or die(mysql_error());
while ($row = mysql_fetch_array($resultat1)) {
$firma[$p] = substr($row['CompanyName'], 0, 44);

$pdf->AddPage(P,A4);

// Create some frame – including some text
$pdf->SetFont('Arial','B', ‘$CompanyName’);
$pdf->SetTextColor(0,0,0);
$pdf->SetXY(10,10);
$pdf->SetDrawColor(240,240,240);
$pdf->Cell(90,54,"$pnavn[$a]",1,1,C);
PayPal

• Free to have - not free to use.
• You need an account.
  Hidden API buildup.
                                         https://cms.paypal.com/us/cgi-bin/?cmd=_render-
•                                        content&content_ID=developer/howto_html_landing




• Create buttons – onsite/offsite.
• Mostly European creditcards.
• Transaction-information related to e.g. invoice
  number.
• PayPal – developer site. (https://www.x.com/developers/paypal)
PayPal – standard call

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="FLFFSFSFSDFL">
<input type="hidden" name="on0" value="Faktura:

<table>
<tr><td nowrap="nowrap">
<font face="Verdana" size="2">Invoice number</font>
<font face="Verdana" size="1"> (Price 5000€.)</font></td></tr><tr><td><input type="text" name="os0" maxlength="200" value="
<?php
echo $workfaknr;
?>
" disabled></td></tr>
<tr><td>&nbsp;</td></tr>
</table>
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way
       to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/da_DK/i/scr/pixel.gif" width="1" height="1">
</form>
PayPal – build up

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="PAYPAL ACCOUNT NAME">
<input type="hidden" name="item_name" value=« Invoice total">
<table>
<tr><td><input type="hidden" name="on0" value="Faktura"><font face="Verdana" size="2">Pick Invoice</font></td></tr><tr><td><select name="os0">
<?php
while ($row = mysql_fetch_array($result1))
{ ... Get invoices... }
<tr><td>&nbsp;</td></tr>
</table>
<?php
Echo "<option value='" . $worknr . "'>" . $worknr . ": " . money_format('%.2n', $Total) . "</option>";
$harray[$worki] = "<input type='hidden' name='option_select" . $worki . "' value='" . $worknr . "'><input type='hidden' name='option_amount" . $worki . "'
        value='" . sprintf("%01.2f", $Ptotal) . "'>";
$worki++;
}
?>
<input type="hidden" name="option_index" value="0">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way
        to pay online!">
  <img alt="" border="0" src="https://www.paypalobjects.com/da_DK/i/scr/pixel.gif" width="1" height="1"></p>
</form>
SMS API

•   External function to call.
•   You may see different setup.
•   Parameter call – cross site
•   API object creation.
•   Call back – with delayed information.

• Other functions as API – e.g. Google.
SMS API

$smsnumber = $wmobil[$i];
$bruger = $_SESSION['navn'];
$nu = date("YmdHis");
$work = $i;

$smsid = $bruger . $nu . $work;

// Build Parameters (RETRY=TRUE som default)
$strParameters =
       "?username=USERNAME!!!!" .
    "&password=CODE!!!" .
    "&dialcode=45" .
    "&recipient=$smsnumber" .
    "&text=" . urlencode(utf8_encode("$sms-text")) .
       "&from=Common+CZ" .
       "&callback_url=" . urlencode("http://www.gs-gruppen.org/GS-SMSs.php?smsid=$smsid&password=RETURNPASSWORD");

//Echo $strParameters;

//Send sms and save output in $strOutput
$strOutput = file_get_contents("http://api.textreactor.com/legacy/sms.php" . $strParameters);
Thank you for your attention!
         Questions

Mais conteúdo relacionado

Mais procurados

PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1Kanchilug
 
Who Needs Ruby When You've Got CodeIgniter
Who Needs Ruby When You've Got CodeIgniterWho Needs Ruby When You've Got CodeIgniter
Who Needs Ruby When You've Got CodeIgniterciconf
 
Apostrophe
ApostropheApostrophe
Apostrophetompunk
 
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learnedMoving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learnedBaldur Rensch
 
Country State City Dropdown in PHP
Country State City Dropdown in PHPCountry State City Dropdown in PHP
Country State City Dropdown in PHPVineet Kumar Saini
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckAnthony Montalbano
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPVineet Kumar Saini
 
Posts ‹ teslaecoenergy — word press php
Posts ‹ teslaecoenergy — word press phpPosts ‹ teslaecoenergy — word press php
Posts ‹ teslaecoenergy — word press phpMiroslav Miskovic
 
Make your own wp cli command in 10min
Make your own wp cli command in 10minMake your own wp cli command in 10min
Make your own wp cli command in 10minIvelina Dimova
 
Top 5 Magento Secure Coding Best Practices
Top 5 Magento Secure Coding Best PracticesTop 5 Magento Secure Coding Best Practices
Top 5 Magento Secure Coding Best PracticesOleksandr Zarichnyi
 
Database Management - Lecture 4 - PHP and Mysql
Database Management - Lecture 4 - PHP and MysqlDatabase Management - Lecture 4 - PHP and Mysql
Database Management - Lecture 4 - PHP and MysqlAl-Mamun Sarkar
 

Mais procurados (15)

PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1
 
Who Needs Ruby When You've Got CodeIgniter
Who Needs Ruby When You've Got CodeIgniterWho Needs Ruby When You've Got CodeIgniter
Who Needs Ruby When You've Got CodeIgniter
 
Pagination in PHP
Pagination in PHPPagination in PHP
Pagination in PHP
 
Apostrophe
ApostropheApostrophe
Apostrophe
 
Payments On Rails
Payments On RailsPayments On Rails
Payments On Rails
 
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learnedMoving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
 
Country State City Dropdown in PHP
Country State City Dropdown in PHPCountry State City Dropdown in PHP
Country State City Dropdown in PHP
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHP
 
Posts ‹ teslaecoenergy — word press php
Posts ‹ teslaecoenergy — word press phpPosts ‹ teslaecoenergy — word press php
Posts ‹ teslaecoenergy — word press php
 
Make your own wp cli command in 10min
Make your own wp cli command in 10minMake your own wp cli command in 10min
Make your own wp cli command in 10min
 
Top 5 Magento Secure Coding Best Practices
Top 5 Magento Secure Coding Best PracticesTop 5 Magento Secure Coding Best Practices
Top 5 Magento Secure Coding Best Practices
 
Database Management - Lecture 4 - PHP and Mysql
Database Management - Lecture 4 - PHP and MysqlDatabase Management - Lecture 4 - PHP and Mysql
Database Management - Lecture 4 - PHP and Mysql
 
Xmpp prebind
Xmpp prebindXmpp prebind
Xmpp prebind
 
Php (1)
Php (1)Php (1)
Php (1)
 

Semelhante a Practical PHP by example Jan Leth-Kjaer

Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3masahiroookubo
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in phpherat university
 
Form demoinplaywithmysql
Form demoinplaywithmysqlForm demoinplaywithmysql
Form demoinplaywithmysqlKnoldus Inc.
 
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 SystemAzharul Haque Shohan
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivityMouli Chandira
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and ImprovedTimothy Fisher
 
Date difference[1]
Date difference[1]Date difference[1]
Date difference[1]shafiullas
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Balázs Tatár
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) ThemingPINGV
 
Ruby on Rails For Java Programmers
Ruby on Rails For Java ProgrammersRuby on Rails For Java Programmers
Ruby on Rails For Java Programmerselliando dias
 

Semelhante a Practical PHP by example Jan Leth-Kjaer (20)

PHP-04-Forms.ppt
PHP-04-Forms.pptPHP-04-Forms.ppt
PHP-04-Forms.ppt
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in php
 
Form demoinplaywithmysql
Form demoinplaywithmysqlForm demoinplaywithmysql
Form demoinplaywithmysql
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Framework
FrameworkFramework
Framework
 
Ip lab
Ip labIp lab
Ip lab
 
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
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
Date difference[1]
Date difference[1]Date difference[1]
Date difference[1]
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
 
Ubi comp27nov04
Ubi comp27nov04Ubi comp27nov04
Ubi comp27nov04
 
Php summary
Php summaryPhp summary
Php summary
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) Theming
 
Ruby on Rails For Java Programmers
Ruby on Rails For Java ProgrammersRuby on Rails For Java Programmers
Ruby on Rails For Java Programmers
 
Rails <form> Chronicle
Rails <form> ChronicleRails <form> Chronicle
Rails <form> Chronicle
 
Tutorial_4_PHP
Tutorial_4_PHPTutorial_4_PHP
Tutorial_4_PHP
 
Tutorial_4_PHP
Tutorial_4_PHPTutorial_4_PHP
Tutorial_4_PHP
 

Mais de COMMON Europe

What's New in WebSphere Application Server
What's New in WebSphere Application ServerWhat's New in WebSphere Application Server
What's New in WebSphere Application ServerCOMMON Europe
 
Compiling the Compiler
Compiling the CompilerCompiling the Compiler
Compiling the CompilerCOMMON Europe
 
Workload Groups overview updates
Workload Groups overview updatesWorkload Groups overview updates
Workload Groups overview updatesCOMMON Europe
 
Why i - Common Europe 2012
Why i - Common Europe 2012Why i - Common Europe 2012
Why i - Common Europe 2012COMMON Europe
 
The Ruby OpenSSL extension
The Ruby OpenSSL extensionThe Ruby OpenSSL extension
The Ruby OpenSSL extensionCOMMON Europe
 
Using Ruby on IBM i (i5/OS)
Using Ruby on IBM i (i5/OS)Using Ruby on IBM i (i5/OS)
Using Ruby on IBM i (i5/OS)COMMON Europe
 
IBM Systems Director Navigator for i
IBM Systems Director Navigator for iIBM Systems Director Navigator for i
IBM Systems Director Navigator for iCOMMON Europe
 
IBM i Trends & Directions Common Europe 2012
IBM i Trends & Directions Common Europe 2012IBM i Trends & Directions Common Europe 2012
IBM i Trends & Directions Common Europe 2012COMMON Europe
 
IBM i Technology Refreshes Overview 2012 06-04
IBM i Technology Refreshes Overview 2012 06-04IBM i Technology Refreshes Overview 2012 06-04
IBM i Technology Refreshes Overview 2012 06-04COMMON Europe
 
IBM i 7.1 & TRs CEC 2012
IBM i 7.1 & TRs CEC 2012IBM i 7.1 & TRs CEC 2012
IBM i 7.1 & TRs CEC 2012COMMON Europe
 
DB2 Web Query whats new
DB2 Web Query whats newDB2 Web Query whats new
DB2 Web Query whats newCOMMON Europe
 
Access client solutions overview
Access client solutions overviewAccess client solutions overview
Access client solutions overviewCOMMON Europe
 
What's new with Zend server
What's new with Zend serverWhat's new with Zend server
What's new with Zend serverCOMMON Europe
 
Php arrays for RPG programmers
Php arrays for RPG programmersPhp arrays for RPG programmers
Php arrays for RPG programmersCOMMON Europe
 
Open source report writing tools for IBM i Vienna 2012
Open source report writing tools for IBM i  Vienna 2012Open source report writing tools for IBM i  Vienna 2012
Open source report writing tools for IBM i Vienna 2012COMMON Europe
 
Moving 5.4 to 7.1 AB
Moving 5.4 to 7.1 ABMoving 5.4 to 7.1 AB
Moving 5.4 to 7.1 ABCOMMON Europe
 
Introduction to My SQL
Introduction to My SQLIntroduction to My SQL
Introduction to My SQLCOMMON Europe
 
IBM CEC 2012 Storage june 11, 2012
IBM CEC 2012 Storage june 11, 2012IBM CEC 2012 Storage june 11, 2012
IBM CEC 2012 Storage june 11, 2012COMMON Europe
 
Getting started with PHP on IBM i
Getting started with PHP on IBM iGetting started with PHP on IBM i
Getting started with PHP on IBM iCOMMON Europe
 

Mais de COMMON Europe (20)

What's New in WebSphere Application Server
What's New in WebSphere Application ServerWhat's New in WebSphere Application Server
What's New in WebSphere Application Server
 
Compiling the Compiler
Compiling the CompilerCompiling the Compiler
Compiling the Compiler
 
Workload Groups overview updates
Workload Groups overview updatesWorkload Groups overview updates
Workload Groups overview updates
 
Why i - Common Europe 2012
Why i - Common Europe 2012Why i - Common Europe 2012
Why i - Common Europe 2012
 
The Ruby OpenSSL extension
The Ruby OpenSSL extensionThe Ruby OpenSSL extension
The Ruby OpenSSL extension
 
Using Ruby on IBM i (i5/OS)
Using Ruby on IBM i (i5/OS)Using Ruby on IBM i (i5/OS)
Using Ruby on IBM i (i5/OS)
 
IBM Systems Director Navigator for i
IBM Systems Director Navigator for iIBM Systems Director Navigator for i
IBM Systems Director Navigator for i
 
IBM i Trends & Directions Common Europe 2012
IBM i Trends & Directions Common Europe 2012IBM i Trends & Directions Common Europe 2012
IBM i Trends & Directions Common Europe 2012
 
IBM i Technology Refreshes Overview 2012 06-04
IBM i Technology Refreshes Overview 2012 06-04IBM i Technology Refreshes Overview 2012 06-04
IBM i Technology Refreshes Overview 2012 06-04
 
IBM i 7.1 & TRs CEC 2012
IBM i 7.1 & TRs CEC 2012IBM i 7.1 & TRs CEC 2012
IBM i 7.1 & TRs CEC 2012
 
DB2 Web Query whats new
DB2 Web Query whats newDB2 Web Query whats new
DB2 Web Query whats new
 
Access client solutions overview
Access client solutions overviewAccess client solutions overview
Access client solutions overview
 
What's new with Zend server
What's new with Zend serverWhat's new with Zend server
What's new with Zend server
 
RPG investment
RPG investmentRPG investment
RPG investment
 
Php arrays for RPG programmers
Php arrays for RPG programmersPhp arrays for RPG programmers
Php arrays for RPG programmers
 
Open source report writing tools for IBM i Vienna 2012
Open source report writing tools for IBM i  Vienna 2012Open source report writing tools for IBM i  Vienna 2012
Open source report writing tools for IBM i Vienna 2012
 
Moving 5.4 to 7.1 AB
Moving 5.4 to 7.1 ABMoving 5.4 to 7.1 AB
Moving 5.4 to 7.1 AB
 
Introduction to My SQL
Introduction to My SQLIntroduction to My SQL
Introduction to My SQL
 
IBM CEC 2012 Storage june 11, 2012
IBM CEC 2012 Storage june 11, 2012IBM CEC 2012 Storage june 11, 2012
IBM CEC 2012 Storage june 11, 2012
 
Getting started with PHP on IBM i
Getting started with PHP on IBM iGetting started with PHP on IBM i
Getting started with PHP on IBM i
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 

Último (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Practical PHP by example Jan Leth-Kjaer

  • 1. PRACTICAL PHP BY EXAMPLE Jan Leth-Kjaer
  • 2. Scope and subjects • This is not a PHP upcode class. • This is not a Zend class. • This is not an Power specific class. • This is not about installation of Apache. • This is not about work management of Pase, PHP or related areas. • This is not a PHP security class.
  • 3. So what is it then? • I presume you all know some type of programming and SQL. • I presume you know HTML at some level. • I presume you can or know a bit of PHP or likewise programming languages. • We will running through a number of practial PHP examples and see the frontend as well as the backend = code.
  • 4. Data management • MySQL – the database. • Retrieve some data. • Show the data. • Give user functionality to enter/update data. • Update the data in database.
  • 5. Data management – go get it <?php session_start(); require("access.php"); // Variabler til mysql hentes $resultat = mysql_query("SELECT * FROM customer WHERE customernumber = '$number'"); while ($row = mysql_fetch_array($resultat)) { $CompanyName = $row['CompanyName']; $Name = $row['Name']; $email = $row['email']; $Address1 = $row['Address1']; $Address2 = $row['Address2']; .... ?> ...... <form action='index.php?page1=CustomerValidate.php method='post' enctype='multipart/form-data'> .... <tr> <td width="193"><font face="Verdana" size="2"><b>Companyname:<font color="#FF0000">*</font></b></font></td> <td colspan="2"><input type="text" name="T1" size="50" tabindex="1" value="<?php echo $CompanyName ; ?>" ></td> </tr>
  • 6. Data management – validate/update $CompanyName = $_POST[‘CompanyName ']; ..... // Validate... if(empty( $CompanyName ) ) { $error1 = '<br> Companyname is empty '; } .... if (preg_match("/^([w|.|-|_]+)@([w||-|_]+).([w|.|-|_]+)$/i", $email-address)) { } else { $error4 = "<br> Email is not correctt!"; } .... Echo $error1 . $error4; ..... mysql_query("UPDATE Customer SET CompanyName = '$CompanyName '..... Where....
  • 7. File management • File management on server. <table border="0" width="50%" cellspacing="10" cellpadding="20"> <?php $path = « foldername"; // Open the folder $dir_handle = @opendir($path) or die("Unable to open $path"); // Loop through the files while ($file = readdir($dir_handle)) { if($file == "." || $file == ".." || substr($file, 0, 10) != 'Nyhedsbrev') continue; $aar = substr($file, 11, 4); $month_number = substr($file, 16, 2); $month_name = date( 'F', mktime(0, 0, 0, $month_number) ); echo "<tr><td width='32' align='left' valign='top'><font face='Verdana' size='2'>"; echo "<font face='Verdana' size='2'>" . $aar . "</td><td><font face='Verdana' size='2'>" . $month_name . "</td><td>"; echo "<font face='Verdana' size='2'><a href='/ foldername /$file'>$file</a></td></tr>"; } // Close closedir($dir_handle); ?> </table>
  • 8. PDF creation • PHP plugin. <?php require('fpdf.php'); http://www.fpdf.org // Get some data – to use.. $resultat1 = mysql_query("SELECT * from meetings where active=‘NEXT'") or die(mysql_error()); while ($row = mysql_fetch_array($resultat1)) { $firma[$p] = substr($row['CompanyName'], 0, 44); $pdf->AddPage(P,A4); // Create some frame – including some text $pdf->SetFont('Arial','B', ‘$CompanyName’); $pdf->SetTextColor(0,0,0); $pdf->SetXY(10,10); $pdf->SetDrawColor(240,240,240); $pdf->Cell(90,54,"$pnavn[$a]",1,1,C);
  • 9. PayPal • Free to have - not free to use. • You need an account. Hidden API buildup. https://cms.paypal.com/us/cgi-bin/?cmd=_render- • content&content_ID=developer/howto_html_landing • Create buttons – onsite/offsite. • Mostly European creditcards. • Transaction-information related to e.g. invoice number. • PayPal – developer site. (https://www.x.com/developers/paypal)
  • 10. PayPal – standard call <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="FLFFSFSFSDFL"> <input type="hidden" name="on0" value="Faktura: <table> <tr><td nowrap="nowrap"> <font face="Verdana" size="2">Invoice number</font> <font face="Verdana" size="1"> (Price 5000€.)</font></td></tr><tr><td><input type="text" name="os0" maxlength="200" value=" <?php echo $workfaknr; ?> " disabled></td></tr> <tr><td>&nbsp;</td></tr> </table> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/da_DK/i/scr/pixel.gif" width="1" height="1"> </form>
  • 11. PayPal – build up <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="PAYPAL ACCOUNT NAME"> <input type="hidden" name="item_name" value=« Invoice total"> <table> <tr><td><input type="hidden" name="on0" value="Faktura"><font face="Verdana" size="2">Pick Invoice</font></td></tr><tr><td><select name="os0"> <?php while ($row = mysql_fetch_array($result1)) { ... Get invoices... } <tr><td>&nbsp;</td></tr> </table> <?php Echo "<option value='" . $worknr . "'>" . $worknr . ": " . money_format('%.2n', $Total) . "</option>"; $harray[$worki] = "<input type='hidden' name='option_select" . $worki . "' value='" . $worknr . "'><input type='hidden' name='option_amount" . $worki . "' value='" . sprintf("%01.2f", $Ptotal) . "'>"; $worki++; } ?> <input type="hidden" name="option_index" value="0"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/da_DK/i/scr/pixel.gif" width="1" height="1"></p> </form>
  • 12. SMS API • External function to call. • You may see different setup. • Parameter call – cross site • API object creation. • Call back – with delayed information. • Other functions as API – e.g. Google.
  • 13. SMS API $smsnumber = $wmobil[$i]; $bruger = $_SESSION['navn']; $nu = date("YmdHis"); $work = $i; $smsid = $bruger . $nu . $work; // Build Parameters (RETRY=TRUE som default) $strParameters = "?username=USERNAME!!!!" . "&password=CODE!!!" . "&dialcode=45" . "&recipient=$smsnumber" . "&text=" . urlencode(utf8_encode("$sms-text")) . "&from=Common+CZ" . "&callback_url=" . urlencode("http://www.gs-gruppen.org/GS-SMSs.php?smsid=$smsid&password=RETURNPASSWORD"); //Echo $strParameters; //Send sms and save output in $strOutput $strOutput = file_get_contents("http://api.textreactor.com/legacy/sms.php" . $strParameters);
  • 14. Thank you for your attention! Questions