slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
PHP INSTALLATION & SAMPLES -BY H. ANKUSH. JAIN PowerPoint Presentation
Download Presentation
PHP INSTALLATION & SAMPLES -BY H. ANKUSH. JAIN

Loading in 2 Seconds...

play fullscreen
1 / 103

PHP INSTALLATION & SAMPLES -BY H. ANKUSH. JAIN - PowerPoint PPT Presentation


  • 128 Views
  • Uploaded on

PHP INSTALLATION & SAMPLES -BY H. ANKUSH. JAIN. Hypertext Preprocessor widely used, general-purpose scripting language a server side scripting language used on the Internet to create dynamic web pages. WHAT IS PHP?. INSTALLATION. 1- Download the latest Windows PHP Binaries (MSI file).

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PHP INSTALLATION & SAMPLES -BY H. ANKUSH. JAIN


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
    Presentation Transcript
    1. PHP INSTALLATION & SAMPLES -BY H. ANKUSH. JAIN

    2. Hypertext Preprocessor widely used, general-purpose scripting language a server side scripting language used on the Internet to create dynamic web pages. WHAT IS PHP?

    3. INSTALLATION

    4. 1- Download the latest Windows PHP Binaries (MSI file) Install PHP 5 on Windows

    5. 2- Right click on the file and click “Install“.

    6. 3- Click “Next ” once the Welcome page is displayed.

    7. 4- Select “I accept the license agreement” and click “Next “.

    8. 5- Change your PHP installation path OR just accept the default path - C:\Program Files\PHP\ and click “Next

    9. 6- On the Web Server Setup screen, select the Apache 2.2.x Module and click “Next

    10. 7-On the Apache Configuration Directory screen, browse for the Apache configuration directory (conf) OR just enter C:\Program Files\Apache Software Foundation\Apache2.2\conf\ and click “Next ” to proceed with the installation.select-apache-webserver-configuration-directory

    11. 8- For now, accept the default selection and click “Next”.

    12. 9-Click “Install ” to install PHP 5 on Windows.

    13. 10- Click “Finish ” once completed. PHP 5 is successfully installed.

    14. 11- Start your Apache 2.2 server using the “Monitor Apache Servers” console (Start -> Apache HTTP Servers 2.2.4 -> Monitor Apache Servers ). You can see that PHP was successfully installed by checking the Apache status at the bottom of the console.

    15. Test your PHP 5 Installation

    16. 1- Open up your Windows Notepad. Type in “<?php phpinfo(); ?>” inside the file. Save this file as “info.php” inside your Apache root directory, C:\Program Files\Apache Software Foundation\Apache2.2\htdocs .

    17. 2- Open up your web browser. In the address bar, type in your web server domain name plus info.php as the file name. Example: http://www.syahid.com/info.php . You should get a PHP configuration page just like the one below.

    18. Congratulations! You have successfully installed and test PHP 5 on Windows!

    19. PHP SAMPLES

    20. <html> <head> <title>Example #1 TDavid's Very First PHP Script ever!</title> </head> <? print(Date("l F d, Y")); ?> <body> </body> </html> Sample 1: current date in an HTML page

    21. <html> <head> <title>Example #3 TDavid's Very First PHP Script ever!</title> </head> <? print(Date("m/j/y")); ?> <body> </body> </html> 2.current month/day/date format

    22. <html> <head> <title>PHP Script examples!</title> </head> <font face="Arial" color="#FF00FF"><strong><? print(Date("m/j/y")); ?> </strong></font> <body> </body> </html> 3. current month/day/date with HTML colors & formatting

    23. <html> <head> <title>Background Colors change based on the day of the week</title> </head> <? $today = date("l"); print("$today"); if($today == "Sunday") { $bgcolor = "#FEF0C5"; } 4. change background color based on day of the week using if else elseif statements

    24. elseif($today == "Monday") { $bgcolor = "#FFFFFF"; } elseif($today == "Tuesday") { $bgcolor = "#FBFFC4"; } elseif($today == "Wednesday") { $bgcolor = "#FFE0DD"; } elseif($today == "Thursday"){ $bgcolor = "#E6EDFF";} 4. change background color based on day of the week using if else elseif statements

    25. elseif($today == "Friday") { $bgcolor = "#E9FFE6"; } else { // Since it is not any of the days above it must be Saturday $bgcolor = "#F0F4F1"; } print("<body bgcolor=\"$bgcolor\">\n"); ?> <br>This just changes the color of the screen based on the day of the week </body> </html> 4. change background color based on day of the week using if else elseif statements

    26. <html> <head> <title>Background Colors change based on the day of the week</title></head> <?$today = date("w"); $bgcolor = array( "#FEF0C5", "#FFFFFF", "#FBFFC4", "#FFE0DD", "#E6EDFF", "#E9FFE6", "#F0F4F1" ); ?> <body bgcolor="<?print("$bgcolor[$today]");?>"> <br>This just changes the color of the screen based on the day of the week </body> </html> 4. change background color based on day of the week using array

    27. <html> <head> <title>Page last updated on month/date/year hour:min PHP Script</title> </head> <? $last_modified = filemtime("example7.php3"); print("Last Modified "); print(date("m/j/y h:i", $last_modified)); ?> </body> </html> 5. add date time stamp "page last updated on.." using filemtime function using forms, cookies, flat file databases, random number generation

    28. <? $check = "test"; $check .= $filename; if ($test == $check) {print("<HTML><BODY>You have already voted. Thank you.</BODY></HTML>"); } else{ $rated = "test"; $rated .= $filename; setcookie(test, $rated, time()+86400); print("<HTML><BODY><br>You haven't voted before so I recorded your vote</BODY></HTML>"); } ?> 6. setting and retrieving a cookie

    29. <? $total_ratings = (3+2+3+1+5+2+3); $total_votes = 7; $average = $total_ratings / $total_votes; print("The Average Rating Is: $average"); ?> 7. getting an average number using PHP

    30. <? $path = "/YOUR/PATH/TO/public_html/php_diary/data"; $filename = "122499.dat"; $x= -1; if($file = fopen("$path/$filename", "r")) { while(!feof($file)) { $therate = fgetss($file, 255); $x++; $count = $count + $therate; } fclose($file); } $average = ($count / $x); print("Surfer Average Rating for 12/24/99: "); printf("%.2f", $average); print("<br>Total Surfer Votes: $x"); ?> 8. showing the surfer average vote statistics, using printf function

    31. <? srand(time()); $random = (rand()%9); print("Random number between 0 and 9 is: $random"); ?> 9. generating a rand number from 0 to 9

    32. <? function slotnumber() { srand(time()); for ($i=0; $i < 3; $i++) { $random = (rand()%3); $slot[] = $random; } print("<td width=\"33%\"><center>$slot[0]</td>"); print("<td width=\"33%\"><center>$slot[1]</td>"); print("<td width=\"33%\"><center>$slot[2]</td>"); </tr> 10. php simple slot machine - multiple rand number generation

    33. <tr> <td width="100%" colspan="3" bgcolor="#008080"><form method="POST" action="example13.php3"><div align="center"><center><p><input type="submit" value="Spin!"></p> </center></div> </form> </td> </tr> </table> </center></div> 11. php simple slot machine - multiple rand number generation

    34. <? $random_url = array("http://www.tdscripts.com/linkorg.html", "http://www.tdscripts.com/keno.html", "http://www.tdscripts.com/ezibill.shtml", "http://www.tdscripts.com/tdforum.shtml", "http://www.tdscripts.com/picofday.html", "http://www.tdscripts.com/gutsorglory.html"); 12. random text link advertising using predefined arraysmail, regular expressions, password protection

    35. $url_title = array("Link Organizer", "TD Keno", "eziBill *Free Promotion!", "TD Forum", "TD Pic of Day PHP", "Guts or Glory Poker PHP"); $url_desc = array("- A comprehensive link list organizer", "- Offer your site visitors an engaging Keno game without the monetary risk", "- Sell access to and protect your membership area using iBill and our eziBill script", "- An unthreaded messageboard script to exchange ideas with your site visitors", "- Run your own picture of the day script from any site anywhere with this handy script", "- A casino-style card game written entirely in PHP"); random text link advertising using predefined arraysmail, regular expressions, password protection

    36. srand(time()); $sizeof = count($random_url); $random = (rand()%$sizeof); print("<center><a href=\"$random_url[$random]\">$url_title[$random]</a> $url_desc[$random]</center>"); ?> random text link advertising using predefined arraysmail, regular expressions, password protection

    37. <? // force all uppercase print(strtoupper("i bet this will show up as all letters capitalized<br>")); // force all lowercase print(strtolower("I BET THIS WILL SHOW UP AS ALL LETTERS IN LOWERCASE<br>")); // force the first letter of a string to be capitalized print(ucfirst("i bet this will show the first letter of the string capitalized<br>")); // force the first letter of each WORD in a string to be capitalized print(ucwords("i bet this will show the first letter of every word capitalized<br>")); ?> 13. forcing the text in a string to be all upper or lowercase

    38. <HTML> <BODY> <? $all_meta = get_meta_tags("010600.php3"); print($all_meta["description"]); print("<br>"); print($all_meta["keywords"]); ?> </BODY> </HTML> 14. searching through meta tags for a search engine

    39. <? $diary_directory = opendir("."); while($filename = readdir($diary_directory)) { $filesplit = explode(".", $filename); $check_filename = $filesplit[0]; if(ereg("[0-9]{6}", $check_filename)) { $check_filename .= ".$filesplit[1]"; $valid_filename[] = $check_filename; } } closedir($diary_directory); for($index = 0; $index < count($valid_filename); $index++) { print("$valid_filename[$index]<br>"); } ?> 15. searching through a directory and picking out files using a regular expression

    40. <? $cards = array("ah", "ac", "ad", "as", "2h", "2c", "2d", "2s", "3h", "3c", "3d", "3s", "4h", "4c", "4d", "4s", "5h", "5c", "5d", "5s", "6h", "6c", "6d", "6s", "7h", "7c", "7d", "7s", "8h", "8c", "8d", "8s", "9h", "9c", "9d", "9s", "th", "tc", "td", "ts", "jh", "jc", "jd", "js", "qh", "qc", "qd", "qs", "kh", "kc", "kd", "ks"); 16. shuffling and "cutting" a deck of playing cards

    41. srand(time()); for($i = 0; $i < 52; $i++) { $count = count($cards); $random = (rand()%$count); if($cards[$random] == "") { $i--; } else { $deck[] = $cards[$random]; $cards[$random] = ""; } } shuffling and "cutting" a deck of playing cards

    42. srand(time()); $starting_point = (rand()%51); print("Starting point for cut cards is: $starting_point<p>"); // display shuffled cards (EXAMPLE ONLY) for ($index = 0; $index < 52; $index++) { if ($starting_point == 52) { $starting_point = 0; } print("Uncut Point: <strong>$deck[$index]</strong> "); print("Starting Point: <strong>$deck[$starting_point]</strong><br>"); $starting_point++; } ?> shuffling and "cutting" a deck of playing cards

    43. <HTML> <HEAD> <title>Reader Rated Most Useful Entries</title> </HEAD> <BODY> <table border="0" width="100%"> <tr> <td width="6%" bgcolor="#00FFFF"><p align="center"><small><font face="Verdana">Rank</font></small></td> <td width="7%" bgcolor="#00FFFF"><p align="center"><small><font face="Verdana">Rating</font></small></td> 17. Reader rated most useful diary entries in descending order

    44. <td width="11%" bgcolor="#00FFFF"><p align="center"><small><font face="Verdana">Diary Date</font></small></td> <td width="76%" bgcolor="#00FFFF"><p align="left"><small><font face="Verdana">Description of Diary Page</font></small> </td> <script language="php"> $db = "DATABASE NAME"; $admin = "MYSQL USER NAME"; $adpass = "MYSQL PASSWORD"; $mysql_link = mysql_connect("localhost", $admin, $adpass); mysql_select_db($db, $mysql_link); Reader rated most useful diary entries in descending order

    45. $query = "SELECT * FROM avg_tally ORDER BY average DESC"; $result = mysql_query($query, $mysql_link); if(mysql_num_rows($result)) { $rank = 1; while($row = mysql_fetch_row($result)) { print("</tr><tr>"); if($color == "#D8DBFE") { $color = "#A6ACFD"; } else { $color = "#D8DBFE"; } print("<td width=\"6%\" bgcolor=\"$color\"><center><small>"); print("<font face=\"Verdana\">$rank</font></small></center></td>"); print("<td width=\"7%\" bgcolor=\"$color\"><center><small>"); print("<font face=\"Verdana\"><strong>$row[1]</strong></font></small></center></td>"); print("<td width=\"11%\" bgcolor=\"$color\"><center><small>"); $url = $row[2] . ".php3"; Reader rated most useful diary entries in descending order

    46. if(!file_exists($url)) { $url = $row[2] . ".html"; } print("<font face=\"Verdana\"><a href=\"$url\">$row[2]</a></font></small></center></td>"); print("<td width=\"76%\" bgcolor=\"$color\"><left><small>"); print("<font face=\"Verdana\">$row[3]</font></small></left></td>"); $rank++; } } </script> </table> </BODY> </HTML> Reader rated most useful diary entries in descending order

    47. <? $mysql_db = "DATABASE NAME"; $mysql_user = "YOUR MYSQL USERNAME"; $mysql_pass = "YOUR MYSQL PASSWORD"; $mysql_link = mysql_connect("localhost", $mysql_user, $mysql_pass); mysql_select_db($mysql_db, $mysql_link); $create_query = "CREATE TABLE tds_counter ( COUNT_ID INT NOT NULL AUTO_INCREMENT, pagepath VARCHAR(250), impressions INT, reset_counter DATETIME, PRIMARY KEY (COUNT_ID) )"; 18. creating a mySQL table using a PHP script

    48. mysql_query($create_query, $mysql_link); print("Table Creation for <b>tds_counter</b> successful!<p>"); $insert = "INSERT into tds_counter VALUES ( 0, '/php_diary/021901.php3', 0, SYSDATE() )"; mysql_query($insert, $mysql_link); print("Inserted new counter successfully for this page: http://www.php-scripts.com/php_diary/021901.php3<p>"); ?> 19. creating a mySQL table using a PHP script

    49. <? $db = "DATABASE NAME"; $admin = "MYSQL USER NAME"; $adpass = "MYSQL PASSWORD"; $mysql_link = mysql_connect("localhost", $admin, $adpass); mysql_select_db($db, $mysql_link); $result = mysql_query("SELECT impressions from tds_counter where COUNT_ID='$cid'", $mysql_link); if(mysql_num_rows($result)) { mysql_query("UPDATE tds_counter set impressions=impressions+1 where COUNT_ID='$cid'", $mysql_link); $row = mysql_fetch_row($result); if($inv != 1) { print("$row[0]"); } }?> 20. mySQL based counter script for multiple pagesAutomating manual tasks, date sorting, mktime()

    50. <?php $bounce = new COM("Chilkat.Bounce"); $success = $bounce->UnlockComponent('Anything for 30-day trial'); if ($success == false) { print 'Failed to unlock component' . "\n"; exit; } $email = new COM("Chilkat.Email"); 21. Classify Email as Bounce (DSN) or Automated Reply