• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Php basics
 

Php basics

on

  • 584 views

Basic PHP

Basic PHP

Statistics

Views

Total Views
584
Views on SlideShare
584
Embed Views
0

Actions

Likes
0
Downloads
44
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Php basics Php basics Presentation Transcript

    • J M Githeko
    • 1. The Tools2. LAMP or WAMP3. Other Web Application Tools4. Download and Install WAMP server –MySQL root password, phpMyAdmin5. Creating a database, securing thedatabase6. Uploading data into the database7. Simple database lookup with PHP
    • HTTPClient 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 namemysql_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:<?phpwhile ($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 databasewhile ($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 MySQL2. Create a database in MSQL and a table to fit the Courses data supplied.3. Import the Courses data into the table4. Create a user with limited privileges over ONLY the new database you have created5. 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.