SlideShare a Scribd company logo
J   M Githeko
1. The Tools
2. LAMP or WAMP
3. Other Web Application Tools
4. Download and Install WAMP server –
MySQL root password, phpMyAdmin
5. Creating a database, securing the
database
6. Uploading data into the database
7. Simple database lookup with PHP
HTTP
Client
                    HTTP Server
(Browser)




                      Scripting
                       Engine




                   Back-End Server
                   (Usually DBMS)
   LAMP: Linux, Apache, MySQL, PHP
   WAMP: Windows, Apache, MySQL, PHP
   Other databases: POSTGRESQL,
    Firebird
   Other scripting engines: Python, Ruby,
    Java/JSP, C#/.Net, Perl,
   Web Frameworks: Struts, .Net AJAX,
    Cold Fusion, Symfony, Django, Zope,
    Rails, Chisimba
   Download WAMP
   Double-click file to start the installation
   Provide info, be careful with MySQL root
    password – write it down, should be a
    strong password
   MySQL Admin tools:
       mysql.exe
       MySQL Administrator
       Phpmyadmin
       Toad for MySQL
       MySQL Workbench
   Locate your WWW and MySQL data
    directories (usually c:wampwww and
    c:wampbin...)
<form name="form" action="semsearch.php"
  method="POST">
 City Name: <input type="text" name=“city" />
  <br />
<input type="submit" name="Submit"
  value="Search" /> <input type="reset"
  name="reset" value="Clear" />
</form>
   Provide login credentials for MySQL
   Select the database to work with
   Connect to database
   Create query(or other SQL command)
    string
   Execute query and save results set
   Build table of results
          Table heading
          Table body
          Table footer
   Close database connections
   Validation of user input
   Security measures – remove dangerous
    code
   Display results using multiple pages for
    large result sets
   Manager user privileges for maximum
    security
<?php
$dbhost = 'localhost'; //MySQL server name
$dbuser = 'ex1'; //User name to be used
$dbpass = 'ex12010'; //User password
$conn = mysql_connect($dbhost, $dbuser,
 $dbpass) or die              ('Error
 connecting to mysql');
$dbname = 'example1'; //database name
mysql_select_db($dbname, $conn); //Connect
 to database
?>
$para=$_POST[„city']
$queryx1= "SELECT sem, code,   title
 FROM courses
  WHERE sem =' $para'"
 $result   = mysql_query($queryx1);
 Header Columns: Country, City, Postal
  Code
<table>
<tr>
<th> Country</th><th>Postal Code
  </th><th> City</th>
</tr>
 Loop through the rows and use records to
  construct the rows:
<?php
while ($row = mysql_fetch_assoc($result)) {
     print "<tr><td>$row[„country']</td>";
     print "<td>$row[code]</td>";
     print "<td>$row[city]</td></tr>";
          }
} ?>
</table>
//fetch tha data from the database

while ($row = mysql_fetch_array($result))
{

    print("<tr><td>".$row[0]."</td><td>".$row[1].
    "</td><td>".$row[2]."</td></tr>“); //display
    the results one table row at a time
}
   Helps prevent unintentional database
    corruption

<?php
</table>
mysql_close($conn);
?>
1.    Install WAMP server or other Apache version that
     includes PHP and MySQL
2.   Create a database in MSQL and a table to fit the Courses
     data supplied.
3.   Import the Courses data into the table
4.   Create a user with limited privileges over ONLY the new
     database you have created
5.   Create a web page with a form to be used for searching
                            A
     the database. Form “action” field should match the name
     of the PHP script.
6.   Create the PHP script to process the form.
7.   Store the web page and PHP script in WWW directory.
8.   Test the scripts ensuring database name, user name,
     password and so on are correct.
Php basics

More Related Content

What's hot

Freeingwebhost
FreeingwebhostFreeingwebhost
Freeingwebhost
Mahkota Raja
 
Image upload in php MySql
Image upload in php MySqlImage upload in php MySql
Image upload in php MySql
Ishaq Shinwari
 
Php basic for vit university
Php basic for vit universityPhp basic for vit university
Php basic for vit university
Mandakini Kumari
 
Message enricher in mule
Message enricher in muleMessage enricher in mule
Message enricher in mule
Sashidhar Rao GDS
 
Getting started into mySQL
Getting started into mySQLGetting started into mySQL
Getting started into mySQL
Siddique Ibrahim
 
CakePHP 3
CakePHP 3CakePHP 3
CakePHP 3
rafaelfqf
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...webhostingguy
 
Phinx talk
Phinx talkPhinx talk
Phinx talk
Michael Peacock
 
1
11
Request dispacther interface ppt
Request dispacther interface pptRequest dispacther interface ppt
Request dispacther interface ppt
Taha Malampatti
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPress
topher1kenobe
 
Php File Upload
Php File UploadPhp File Upload
Php File Upload
Hiroaki Kawai
 
Uploading a file with php
Uploading a file with phpUploading a file with php
Uploading a file with php
Muhamad Al Imran
 
PHP - Intriduction to MySQL And PHP
PHP - Intriduction to MySQL And PHPPHP - Intriduction to MySQL And PHP
PHP - Intriduction to MySQL And PHP
Vibrant Technologies & Computers
 
Php Training Workshop by Vtips
Php Training Workshop by VtipsPhp Training Workshop by Vtips
Php Training Workshop by Vtips
Vidya Topa Institute of Professional Studies
 
REST API with CakePHP
REST API with CakePHPREST API with CakePHP
REST API with CakePHP
Anuchit Chalothorn
 
MySQLi - An Improved Extension of MySQL
MySQLi - An Improved Extension of MySQLMySQLi - An Improved Extension of MySQL
MySQLi - An Improved Extension of MySQL
Global Codester
 
php $_GET / $_POST / $_SESSION
php  $_GET / $_POST / $_SESSIONphp  $_GET / $_POST / $_SESSION
php $_GET / $_POST / $_SESSION
tumetr1
 
eZ Publish Cluster Unleashed
eZ Publish Cluster UnleashedeZ Publish Cluster Unleashed
eZ Publish Cluster Unleashed
Bertrand Dunogier
 
extending-php
extending-phpextending-php
extending-php
tutorialsruby
 

What's hot (20)

Freeingwebhost
FreeingwebhostFreeingwebhost
Freeingwebhost
 
Image upload in php MySql
Image upload in php MySqlImage upload in php MySql
Image upload in php MySql
 
Php basic for vit university
Php basic for vit universityPhp basic for vit university
Php basic for vit university
 
Message enricher in mule
Message enricher in muleMessage enricher in mule
Message enricher in mule
 
Getting started into mySQL
Getting started into mySQLGetting started into mySQL
Getting started into mySQL
 
CakePHP 3
CakePHP 3CakePHP 3
CakePHP 3
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
 
Phinx talk
Phinx talkPhinx talk
Phinx talk
 
1
11
1
 
Request dispacther interface ppt
Request dispacther interface pptRequest dispacther interface ppt
Request dispacther interface ppt
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPress
 
Php File Upload
Php File UploadPhp File Upload
Php File Upload
 
Uploading a file with php
Uploading a file with phpUploading a file with php
Uploading a file with php
 
PHP - Intriduction to MySQL And PHP
PHP - Intriduction to MySQL And PHPPHP - Intriduction to MySQL And PHP
PHP - Intriduction to MySQL And PHP
 
Php Training Workshop by Vtips
Php Training Workshop by VtipsPhp Training Workshop by Vtips
Php Training Workshop by Vtips
 
REST API with CakePHP
REST API with CakePHPREST API with CakePHP
REST API with CakePHP
 
MySQLi - An Improved Extension of MySQL
MySQLi - An Improved Extension of MySQLMySQLi - An Improved Extension of MySQL
MySQLi - An Improved Extension of MySQL
 
php $_GET / $_POST / $_SESSION
php  $_GET / $_POST / $_SESSIONphp  $_GET / $_POST / $_SESSION
php $_GET / $_POST / $_SESSION
 
eZ Publish Cluster Unleashed
eZ Publish Cluster UnleashedeZ Publish Cluster Unleashed
eZ Publish Cluster Unleashed
 
extending-php
extending-phpextending-php
extending-php
 

Viewers also liked

PHP 1
PHP 1PHP 1
Android ui with xml
Android ui with xmlAndroid ui with xml
Android ui with xml
Egerton University
 
SharePoint 2010 Sandboxed Solution
SharePoint 2010 Sandboxed SolutionSharePoint 2010 Sandboxed Solution
SharePoint 2010 Sandboxed Solution
Srini Sistla
 
Els nous mitjans
Els nous mitjansEls nous mitjans
Els nous mitjansxamara
 
A few words about WAMP
A few words about WAMPA few words about WAMP
A few words about WAMP
Konstantin Burkalev
 
PHP for HTML Gurus - J and Beyond 2012
PHP for HTML Gurus - J and Beyond 2012PHP for HTML Gurus - J and Beyond 2012
PHP for HTML Gurus - J and Beyond 2012
Andrea Tarr
 

Viewers also liked (6)

PHP 1
PHP 1PHP 1
PHP 1
 
Android ui with xml
Android ui with xmlAndroid ui with xml
Android ui with xml
 
SharePoint 2010 Sandboxed Solution
SharePoint 2010 Sandboxed SolutionSharePoint 2010 Sandboxed Solution
SharePoint 2010 Sandboxed Solution
 
Els nous mitjans
Els nous mitjansEls nous mitjans
Els nous mitjans
 
A few words about WAMP
A few words about WAMPA few words about WAMP
A few words about WAMP
 
PHP for HTML Gurus - J and Beyond 2012
PHP for HTML Gurus - J and Beyond 2012PHP for HTML Gurus - J and Beyond 2012
PHP for HTML Gurus - J and Beyond 2012
 

Similar to Php basics

Php summary
Php summaryPhp summary
Php summary
Michelle Darling
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
WalaSidhom1
 
Php classes in mumbai
Php classes in mumbaiPhp classes in mumbai
Php classes in mumbai
aadi Surve
 
harry presentation
harry presentationharry presentation
harry presentation
thembhani mapengo
 
Learn PHP Lacture2
Learn PHP Lacture2Learn PHP Lacture2
Learn PHP Lacture2
ADARSH BHATT
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
Adrien Guéret
 
PHP - Getting good with MySQL part II
 PHP - Getting good with MySQL part II PHP - Getting good with MySQL part II
PHP - Getting good with MySQL part II
Firdaus Adib
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
Mudasir Syed
 
(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...
(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...
(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...
Amazon Web Services
 
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
Amazon Web Services
 
phptut4
phptut4phptut4
phptut4
tutorialsruby
 
phptut4
phptut4phptut4
phptut4
tutorialsruby
 
Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)
vibrantuser
 
MySQL with PHP
MySQL with PHPMySQL with PHP
MySQL with PHP
MsSJeyalakshmiVelsUn
 
Database Connection With Mysql
Database Connection With MysqlDatabase Connection With Mysql
Database Connection With Mysql
Harit Kothari
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actions
Aren Zomorodian
 
Rack
RackRack
Synapse india basic php development part 1
Synapse india basic php development part 1Synapse india basic php development part 1
Synapse india basic php development part 1
Synapseindiappsdevelopment
 
Facebook的缓存系统
Facebook的缓存系统Facebook的缓存系统
Facebook的缓存系统
yiditushe
 
Php session
Php sessionPhp session
Php session
argusacademy
 

Similar to Php basics (20)

Php summary
Php summaryPhp summary
Php summary
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Php classes in mumbai
Php classes in mumbaiPhp classes in mumbai
Php classes in mumbai
 
harry presentation
harry presentationharry presentation
harry presentation
 
Learn PHP Lacture2
Learn PHP Lacture2Learn PHP Lacture2
Learn PHP Lacture2
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
PHP - Getting good with MySQL part II
 PHP - Getting good with MySQL part II PHP - Getting good with MySQL part II
PHP - Getting good with MySQL part II
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
 
(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...
(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...
(APP202) Deploy, Manage, Scale Apps w/ AWS OpsWorks & AWS Elastic Beanstalk |...
 
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
 
phptut4
phptut4phptut4
phptut4
 
phptut4
phptut4phptut4
phptut4
 
Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)
 
MySQL with PHP
MySQL with PHPMySQL with PHP
MySQL with PHP
 
Database Connection With Mysql
Database Connection With MysqlDatabase Connection With Mysql
Database Connection With Mysql
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actions
 
Rack
RackRack
Rack
 
Synapse india basic php development part 1
Synapse india basic php development part 1Synapse india basic php development part 1
Synapse india basic php development part 1
 
Facebook的缓存系统
Facebook的缓存系统Facebook的缓存系统
Facebook的缓存系统
 
Php session
Php sessionPhp session
Php session
 

More from Egerton University

COMP340 TOPIC 4 THREE.JS.pptx
COMP340 TOPIC 4 THREE.JS.pptxCOMP340 TOPIC 4 THREE.JS.pptx
COMP340 TOPIC 4 THREE.JS.pptx
Egerton University
 
Event handler example
Event handler exampleEvent handler example
Event handler example
Egerton University
 
Android programming basics
Android programming basicsAndroid programming basics
Android programming basics
Egerton University
 
javascript examples
javascript examplesjavascript examples
javascript examples
Egerton University
 
Website management
Website managementWebsite management
Website management
Egerton University
 
My sql command line client
My sql command line clientMy sql command line client
My sql command line client
Egerton University
 

More from Egerton University (6)

COMP340 TOPIC 4 THREE.JS.pptx
COMP340 TOPIC 4 THREE.JS.pptxCOMP340 TOPIC 4 THREE.JS.pptx
COMP340 TOPIC 4 THREE.JS.pptx
 
Event handler example
Event handler exampleEvent handler example
Event handler example
 
Android programming basics
Android programming basicsAndroid programming basics
Android programming basics
 
javascript examples
javascript examplesjavascript examples
javascript examples
 
Website management
Website managementWebsite management
Website management
 
My sql command line client
My sql command line clientMy sql command line client
My sql command line client
 

Recently uploaded

The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 

Recently uploaded (20)

The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 

Php basics

  • 1. J M Githeko
  • 2. 1. The Tools 2. LAMP or WAMP 3. Other Web Application Tools 4. Download and Install WAMP server – MySQL root password, phpMyAdmin 5. Creating a database, securing the database 6. Uploading data into the database 7. Simple database lookup with PHP
  • 3. HTTP Client HTTP Server (Browser) Scripting Engine Back-End Server (Usually DBMS)
  • 4. LAMP: Linux, Apache, MySQL, PHP  WAMP: Windows, Apache, MySQL, PHP  Other databases: POSTGRESQL, Firebird  Other scripting engines: Python, Ruby, Java/JSP, C#/.Net, Perl,  Web Frameworks: Struts, .Net AJAX, Cold Fusion, Symfony, Django, Zope, Rails, Chisimba
  • 5. Download WAMP  Double-click file to start the installation  Provide info, be careful with MySQL root password – write it down, should be a strong password  MySQL Admin tools:  mysql.exe  MySQL Administrator  Phpmyadmin  Toad for MySQL  MySQL Workbench  Locate your WWW and MySQL data directories (usually c:wampwww and c:wampbin...)
  • 6. <form name="form" action="semsearch.php" method="POST"> City Name: <input type="text" name=“city" /> <br /> <input type="submit" name="Submit" value="Search" /> <input type="reset" name="reset" value="Clear" /> </form>
  • 7. Provide login credentials for MySQL  Select the database to work with  Connect to database  Create query(or other SQL command) string  Execute query and save results set  Build table of results Table heading Table body Table footer  Close database connections
  • 8. Validation of user input  Security measures – remove dangerous code  Display results using multiple pages for large result sets  Manager user privileges for maximum security
  • 9. <?php $dbhost = 'localhost'; //MySQL server name $dbuser = 'ex1'; //User name to be used $dbpass = 'ex12010'; //User password $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'example1'; //database name mysql_select_db($dbname, $conn); //Connect to database ?>
  • 10. $para=$_POST[„city'] $queryx1= "SELECT sem, code, title FROM courses WHERE sem =' $para'"
  • 11.  $result = mysql_query($queryx1);
  • 12.
  • 13.  Header Columns: Country, City, Postal Code <table> <tr> <th> Country</th><th>Postal Code </th><th> City</th> </tr>
  • 14.  Loop through the rows and use records to construct the rows: <?php while ($row = mysql_fetch_assoc($result)) { print "<tr><td>$row[„country']</td>"; print "<td>$row[code]</td>"; print "<td>$row[city]</td></tr>"; } } ?> </table>
  • 15. //fetch tha data from the database while ($row = mysql_fetch_array($result)) { print("<tr><td>".$row[0]."</td><td>".$row[1]. "</td><td>".$row[2]."</td></tr>“); //display the results one table row at a time }
  • 16. Helps prevent unintentional database corruption <?php </table> mysql_close($conn); ?>
  • 17. 1. Install WAMP server or other Apache version that includes PHP and MySQL 2. Create a database in MSQL and a table to fit the Courses data supplied. 3. Import the Courses data into the table 4. Create a user with limited privileges over ONLY the new database you have created 5. Create a web page with a form to be used for searching A the database. Form “action” field should match the name of the PHP script. 6. Create the PHP script to process the form. 7. Store the web page and PHP script in WWW directory. 8. Test the scripts ensuring database name, user name, password and so on are correct.