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);
Php basics
 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

PPT
Wordpress install setup
PDF
Php workshop L04 database
PPTX
Cake PHP 3 Presentaion
PDF
Php workshop L03 superglobals
PPT
PHP and MySQL
PPTX
System performance tuning
PPT
Zend Con 2008 Slides
PPT
Mysql grand
Wordpress install setup
Php workshop L04 database
Cake PHP 3 Presentaion
Php workshop L03 superglobals
PHP and MySQL
System performance tuning
Zend Con 2008 Slides
Mysql grand

What's hot (20)

DOCX
Freeingwebhost
PPTX
Image upload in php MySql
PPT
Php basic for vit university
PPTX
Message enricher in mule
PPT
Getting started into mySQL
PDF
CakePHP 3
PPT
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PDF
Phinx talk
PPTX
PPTX
Request dispacther interface ppt
PPTX
Working with WP_Query in WordPress
ODP
Php File Upload
PPTX
Uploading a file with php
PPT
PHP - Intriduction to MySQL And PHP
PPTX
Php Training Workshop by Vtips
PDF
REST API with CakePHP
PPT
MySQLi - An Improved Extension of MySQL
PPT
php $_GET / $_POST / $_SESSION
PPT
eZ Publish Cluster Unleashed
PDF
extending-php
Freeingwebhost
Image upload in php MySql
Php basic for vit university
Message enricher in mule
Getting started into mySQL
CakePHP 3
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
Phinx talk
Request dispacther interface ppt
Working with WP_Query in WordPress
Php File Upload
Uploading a file with php
PHP - Intriduction to MySQL And PHP
Php Training Workshop by Vtips
REST API with CakePHP
MySQLi - An Improved Extension of MySQL
php $_GET / $_POST / $_SESSION
eZ Publish Cluster Unleashed
extending-php
Ad

Viewers also liked (6)

PPTX
Android ui with xml
PPT
SharePoint 2010 Sandboxed Solution
PPS
Els nous mitjans
PDF
A few words about WAMP
PPTX
PHP for HTML Gurus - J and Beyond 2012
Android ui with xml
SharePoint 2010 Sandboxed Solution
Els nous mitjans
A few words about WAMP
PHP for HTML Gurus - J and Beyond 2012
Ad

Similar to Php basics (20)

PDF
Php summary
PPTX
CHAPTER six DataBase Driven Websites.pptx
PPT
nodejs_at_a_glance, understanding java script
PPT
nodejs_at_a_glance.ppt
PPT
Php classes in mumbai
PPTX
harry presentation
PPTX
Learn PHP Lacture2
PPTX
Introduction to node.js
PPT
PHP - Getting good with MySQL part II
PPT
Php Mysql
PDF
phptut4
PDF
phptut4
PPT
Sql php-vibrant course-mumbai(1)
PPTX
MySQL with PHP
ODP
Database Connection With Mysql
PPTX
Web Technologies - forms and actions
PDF
PPTX
Synapse india basic php development part 1
PDF
Facebook的缓存系统
PPSX
Php session
Php summary
CHAPTER six DataBase Driven Websites.pptx
nodejs_at_a_glance, understanding java script
nodejs_at_a_glance.ppt
Php classes in mumbai
harry presentation
Learn PHP Lacture2
Introduction to node.js
PHP - Getting good with MySQL part II
Php Mysql
phptut4
phptut4
Sql php-vibrant course-mumbai(1)
MySQL with PHP
Database Connection With Mysql
Web Technologies - forms and actions
Synapse india basic php development part 1
Facebook的缓存系统
Php session

More from Egerton University (6)

PPTX
COMP340 TOPIC 4 THREE.JS.pptx
PPTX
Event handler example
PPTX
Android programming basics
PPT
javascript examples
PPTX
Website management
PPTX
My sql command line client
COMP340 TOPIC 4 THREE.JS.pptx
Event handler example
Android programming basics
javascript examples
Website management
My sql command line client

Recently uploaded (20)

PDF
Complications of Minimal Access Surgery at WLH
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Yogi Goddess Pres Conference Studio Updates
PPTX
Microbial diseases, their pathogenesis and prophylaxis
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Trump Administration's workforce development strategy
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
master seminar digital applications in india
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Final Presentation General Medicine 03-08-2024.pptx
Complications of Minimal Access Surgery at WLH
O5-L3 Freight Transport Ops (International) V1.pdf
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
A systematic review of self-coping strategies used by university students to ...
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Final Presentation General Medicine 03-08-2024.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Yogi Goddess Pres Conference Studio Updates
Microbial diseases, their pathogenesis and prophylaxis
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Trump Administration's workforce development strategy
Microbial disease of the cardiovascular and lymphatic systems
master seminar digital applications in india
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
GDM (1) (1).pptx small presentation for students
Final Presentation General Medicine 03-08-2024.pptx

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);
  • 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.