SlideShare ist ein Scribd-Unternehmen logo
1 von 18
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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (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
 

Andere mochten auch

SharePoint 2010 Sandboxed Solution
SharePoint 2010 Sandboxed SolutionSharePoint 2010 Sandboxed Solution
SharePoint 2010 Sandboxed SolutionSrini Sistla
 
Els nous mitjans
Els nous mitjansEls nous mitjans
Els nous mitjansxamara
 
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 2012Andrea Tarr
 

Andere mochten auch (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
 

Ähnlich wie Php basics

nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.pptWalaSidhom1
 
Php classes in mumbai
Php classes in mumbaiPhp classes in mumbai
Php classes in mumbaiaadi Surve
 
Learn PHP Lacture2
Learn PHP Lacture2Learn PHP Lacture2
Learn PHP Lacture2ADARSH BHATT
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsAdrien 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 IIFirdaus Adib
 
(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
 
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
 
Database Connection With Mysql
Database Connection With MysqlDatabase Connection With Mysql
Database Connection With MysqlHarit Kothari
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actionsAren Zomorodian
 
Facebook的缓存系统
Facebook的缓存系统Facebook的缓存系统
Facebook的缓存系统yiditushe
 

Ähnlich wie 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
 

Mehr von Egerton University

Mehr von 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
 

Kürzlich hochgeladen

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
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.MaryamAhmad92
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
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.pptxMaritesTamaniVerdade
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 

Kürzlich hochgeladen (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
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.
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.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
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

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.