SlideShare a Scribd company logo
10 th  planet Technologies ArjunRaj.d Php Install Uninstall Setup Configure Samples
Installation, setup and configure  PHP-Fusion download PHP-Fusion After unpacking the file The file readme-xx.HTML (indifferent language versions) stipulates the conditions for using PHP-Fusion (GNU - GPL) and the main instructions for the installation.  the installation process by making a new MySQL database or by getting your provider to create one for you on the web server where your web-page will reside.
copy all the files in the folder php-files to the root of the web server (by using a FTP-program such as CuteFTP or SmartFTP).  set the permissions on a number of files and folders for the installation process to run smoothly The README files refer to the CHMOD command
to ‘change the mode’ of the file, which is simply setting the file or folder permissions. these permissions either through your FTP-program or via the interface solution provided by your service provider. Readme-xx.html
set the permissions1: The folders and files: administration/db_backups/ · images/ · images/imagelist.js · images/articles/ · images/avatars/ · images/news/
· images/news_cats/ · images/photoalbum/ · images/photoalbum/submissions/ · forum/attachments/ · config.php - should be set to 777.  code 777 means, that these folders should have the permissions:
Installing PHP-Fusion step 1 Here you start out by choosing the language in which the dialogue of the installation process will proceed (the number of languages will grow rapidly in the near future). In this example we choose ‘English’. If you choose another language, the language of the setup screen will change. But here we just fill out the fields in the form – like this – and click ‘ Next’: PHPFusion_setup_1.PNG
the language of the setup screen
Step 2
Step 3
Step 4
Step 5
Step 6 CONGRATULATION!!! You’ve already successfully installed PHP-Fusion.Enjoy using PHP
<? print(&quot;Hello World&quot;) ?> <?=&quot;Hello World&quot;?>
Set background color from a drop-down list.  <!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;> <html> <head> <title>Change background color from a drop-down list</title> <script> <!-- function changeColor(newColor) { DHTMLSafe=aeObjects[&quot;test&quot;];
DHTMLSafe.DOM.body.style.backgroundColor = newColor; document.all.colorPicker.selectedIndex = 0;  }//--> </script>  </head>
</head> <body> <% Session(&quot;userid&quot;) = &quot;1&quot; imageurl = &quot;/images&quot; + Session(&quot;userid&quot;) + &quot;/&quot; imagepath = &quot;c:Inetpubwwwrootimages&quot; + Session(&quot;userid&quot;) %>
<%Set ae= Server.CreateObject(&quot;CFDEV.Activedit&quot;) ae.AllowEditSource=true ae.QuickFonts=&quot;Arial, Courier&quot; ae.DefaultFont=&quot;10pt Arial&quot; ae.BaseURL=&quot;http://localhost&quot; ae.Border=&quot;1px solid black&quot; ae.BreakOnEnter=true
ae.Width=&quot;50%&quot; ae.Height=&quot;50%&quot; ae.Name=&quot;test&quot; ae.Inc=&quot;inc/&quot; ae.ImagePath=imagepath ae.ImageURL=imageurl ae.AllowUpload=true
ae.Toolbar=&quot;quickformat,quickfont, quickfontsize,|,cut,copy,paste,|,redo,undo,|,font,bold,italic,underline,|,outdent,indent,|,justifyleft,justifycenter,justifyright,bullets,|,table,image,hyperlink,|,find,help&quot; ae.Content=&quot;Default Content&quot; %>
<form action=&quot;action.asp&quot; method=&quot;post&quot;> <select id=&quot;colorPicker&quot; onChange=&quot;changeColor(this.options[this.selectedIndex].value)&quot;> <option>Background Color <option value=&quot;0000FF&quot;>Blue <option value=&quot;FF0000&quot;>Red <option value=&quot;00FF00&quot;>Green
<option value=&quot;000000&quot;>Black </select> <% ae.Write() %> <% ae.Name=&quot;test2&quot; ae.Write() %> <INPUT TYPE=&quot;SUBMIT&quot;></form> </body> </html>
Print the current date using php's date formatting function date September 3rd, 2002 <? print date(&quot;F jS, Y&quot;); ?> mm/dd/yyyy <? print date(&quot;m/j/Y&quot;); ?> mm/dd/yy <? print date(&quot;m/j/y&quot;); ?>
Format the current time with the php date function h:mm:ss (24 hour) <? print date(&quot;H:i:s&quot;); ?> h:mm:ss (12 hour) <? print date(&quot;h:i:s&quot;); ?> h:mm:ss (AM/PM) <? print date(&quot;h:i:s A&quot;); ?>
Print out environment variables. Place the following in a file named variables.inc in the current directory. <?php // Print Environment Variables echo &quot;<b>Environment Variables from $HTTP_ENV_VARS</b><br><br>&quot;; reset($HTTP_ENV_VARS); while (list ($key, $val) = each ($HTTP_ENV_VARS)) { print $key . &quot; = &quot; . $val . &quot;<br>&quot;; }
// Print GET Variables  echo &quot;<br>&quot;; echo &quot;<b>GET Variables from $HTTP_GET_VARS</b><br><br>&quot;; reset($HTTP_GET_VARS); while (list ($key, $val) = each ($HTTP_GET_VARS)) { print $key . &quot; = &quot; . $val . &quot;<br>&quot;; }// Print POST Variables  echo &quot;<br>&quot;;
echo &quot;<b>POST Variables from $HTTP_POST_VARS</b><br><br>&quot;; reset($HTTP_POST_VARS); while (list ($key, $val) = each ($HTTP_POST_VARS)) { print $key . &quot; = &quot; . $val . &quot;<br>&quot;; }// Print COOKIE Variables  echo &quot;<br>&quot;;
echo &quot;<b>COOKIE Variables from $HTTP_COOKIE_VARS</b><br><br>&quot;; reset($HTTP_COOKIE_VARS); while (list ($key, $val) = each ($HTTP_COOKIE_VARS)) { print $key . &quot; = &quot; . $val . &quot;<br>&quot;; }
// Print SESSION Variables echo &quot;<br>&quot;; echo &quot;<b>SESSION Variables from $HTTP_SESSION_VARS</b><br><br>&quot;; reset($HTTP_SESSION_VARS); while (list ($key, $val) = each ($HTTP_SESSION_VARS)) { print $key . &quot; = &quot; . $val . &quot;<br>&quot;; }?>
Call the file with the following at any point in your page where you would like the variables output. <?php require(&quot;variables.inc&quot;); ?>
Convert common user input to a boolean <?php /* The stringToBoolean function accepts a string and returns a boolean. This is a nice function to handle user input for a boolean, which may be 0, false, False, no or No, for example.*/function stringToBoolean($str) { $str = trim(strtolower($str)); if ($str == &quot;0&quot; || $str == &quot;false&quot; || $str == &quot;no&quot;) {  return 0; }else {  return 1 } }
// Code to test stringToBoolean() $strings = array(&quot;false&quot;,&quot;no&quot;,&quot;test&quot;,&quot;string&quot;,&quot;False&quot;,0); foreach($strings as $string) { print &quot;$string : &quot;; print stringToBoolean($string)? &quot;True&quot;:&quot;False&quot;; print &quot;<br> &quot;;}?>
Handling amounts of data to be divided into several pages... <?php /* NAME  'list_from_db.inc' //Lists records from DB - line by line with href/link to a 'detail-page' // USED IN  Page for showing a list of news from your database. //  The scrict handles amounts that has to be divided into several &quot;pages&quot;, //  and builds links to all pages  - including  PRIOR and NEXT.///  ADJUSTMENTS to be made before use:
$curr_page - points to &quot;CURRENT&quot; page AND MUST BE SET TO 1 IN THE CALLING PAGE //  ex.: in index.php  ...<a href=news.php?ID=1</a>in news.php  <?php $curr_page=$_GET['ID']; ?> // $max_page  - max number of listings (newslines) you want on your/each page details.php - this is the page for showing details in the newsline. Adjust the name...myself.php - this is the page where this script is included. Adjust the name... table etc - adjust the names to fit your DB connection  - adjust this to fit your DB
mysql_connect('localhost', 'user_name', 'pass_word'); mysql_select_db('your_db'); //adjust these variables to fit your page //$max_page = 20;  /* set the number that fits your case */ $query = &quot;SELECT * FROM tableWHERE ...ORDER BY ...&quot;;$result = mysql_query($query); $max_rows = mysql_num_rows($result);
// Did we find any data? if ($max_rows >0) { // need to be shure if we have a full page - or more... $max_pages = intval($max_rows / $max_page) +1;//$max_pages = intval($max_pages)+1; $row_num = $max_page * ($curr_page-1); $num_list = 1;$num_lines = 0; $max_lines = $max_page + 5;
pointer of tablerow works from fra 0 til max_rows -1//while ($row_num <= $max_rows-1) { mysql_data_seek($result,$row_num); $row = mysql_fetch_array($result); if ($num_list <= $max_page) { $row_num++; $year  = intval(substr($row[3],2,2)); $month = intval(substr($row[3],5,2)); $day  = intval(substr($row[3],8,2)); row[1] keeps the headline for the record
print(&quot;<TABLE BORDER=0>&quot;); print(&quot;<TR>&quot;); echo &quot;<TD width=5><font face= Verdana, sans-serif  size=2>-</TD></font>&quot;;echo &quot;<TD width=365><font face= Verdana, sans-serif  size=2><a href=&quot;details.php?ID=$row[0]>$row[1] </a> -  $day/$month-0$year</TD></font>&quot;; print(&quot;</TR>&quot;); print(&quot;</TABLE>&quot;);$num_lines++; $num_list++; } else { break; }  }
if ($max_pages > 1) { Puts blank lines to adjust the &quot;page-info line&quot; on the same place each time  //while ($num_lines < $max_lines) {echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;2&quot;><br></font>&quot;;$num_lines++; }Writes the page-info-line - and removes the LINK to &quot;current page&quot;  //-----echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;2&quot;><br><br><b>&quot;;$prior  = $curr_page - 1;$next  = $curr_page + 1;
if ($curr_page > 1) { echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;1&quot;> <a href=&quot;myself.php?ID=$prior>Prior </a></font>&quot;;  } $page=1; while ($page <= $max_pages) {
if ($max_pages > 1) { echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;1&quot; color=&quot;#999999&quot;> $page</font>&quot;; }  } else {echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;1&quot; color=&quot;#000000&quot;> <a href=&quot;myself.php?ID=$page>$page</a></font>&quot;;}$page++;  }
if ($curr_page < $max_pages) { echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;1&quot;> <a href=&quot;myself.php?ID=$next> Next</a></font>&quot;; } } } else {
echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;2&quot;>No data found</font>&quot;; }
User to set the background color and text color <body bgcolor=<?=$_GET[&quot;bg&quot;]?> text=<?=$_GET[&quot;txt&quot;]?>><center><form method=&quot;GET&quot;> <input type=&quot;text&quot; value=&quot;Background Color&quot; name=&quot;bg&quot;> <input type=&quot;text&quot; value=&quot;Text Color&quot; name=&quot;txt&quot;> <input type=&quot;hidden&quot; value=1 name=done> <input type=&quot;submit&quot; value=&quot;Change&quot;> <input type=&quot;reset&quot; value=reset></form><?
if (isset($_GET[&quot;done&quot;])) {if ($_GET[&quot;bg&quot;]==&quot;YOUR SPECIFIC BACKGROUND COLOR&quot;) {if ($_GET[&quot;txt&quot;]==&quot;YOUR SPECIFIC TEXT COLOR&quot;) { echo &quot;YOUR TEXT IF COLORS ARE USED&quot;; } else {echo &quot;You are using $_GET[bg] for your background color and $_GET[txt] for your text color&quot;; }
}else {echo &quot;You are using $_GET[bg] for your background color and $_GET[txt] for your text color&quot;; }}else { echo &quot;<font color=white>Choose something</font>&quot;; } ?>
<TABLE cellSpacing=1 cellPadding=2 bgColor=black border=0> <TR bgColor=white> <TD>First</TD> <TD>Last</TD> <TD>Email<TD> </TR> </TABLE> <?
mysql_connect(&quot;localhost&quot;, &quot;db user&quot;, &quot;db pass&quot;)or die(&quot;DB CONNECT ERROR: &quot; . mysql_error()); mysql_select_db(&quot;db name&quot;) or die(&quot;DB SELECT ERROR: &quot; . mysql_error()); $query = &quot;SELECT fname, lname, email FROM table ORDER BY lname&quot;; $result = mysql_query($query) or die(&quot;DB SELECT ERROR: &quot; . mysql_error());
while($row = mysql_fetch_array($result)) {$lname = $row['lname'];$fname = $row['fname'];$email = $row['email']; ?><TR bgColor=white><TD><?=$fname?></TD><TD><?=$lname?></TD><TD><?=$email?><TD></TR> </TABLE> <?
Time left using unix time stamp function time_left($integer)  { $seconds=$integer;  if ($seconds/60 >=1)  {  $minutes=floor($seconds/60);  if ($minutes/60 >= 1)  { # Hours  $hours=floor($minutes/60);  if ($hours/24 >= 1) { #days  $days=floor($hours/24);  if ($days/7 >=1){ #weeks
$weeks=floor($days/7);  if ($weeks>=2) $return=&quot;$weeks Weeks&quot;;  else $return=&quot;$weeks Week&quot;;  } #end of weeks $days=$days-(floor($days/7))*7;  if ($weeks>=1 && $days >=1) $return=&quot;$return, &quot;;  if ($days >=2) $return=&quot;$return $days days&quot;;  if ($days ==1) $return=&quot;$return $days day&quot;;  } #end of days
$hours=$hours-(floor($hours/24))*24;  if ($days>=1 && $hours >=1) $return=&quot;$return, &quot;;  if ($hours >=2) $return=&quot;$return $hours hours&quot;;  if ($hours ==1) $return=&quot;$return $hourshour&quot;;  } #end of Hours
$minutes=$minutes-(floor($minutes/60))*60;  if ($hours>=1 && $minutes >=1) $return=&quot;$return, &quot;;  if ($minutes >=2) $return=&quot;$return $minutes minutes&quot;;  if ($minutes ==1) $return=&quot;$return $minutes minute&quot;; } #end of minutes  $seconds=$integer-(floor($integer/60))*60;  if ($minutes>=1 && $seconds >=1) $return=&quot;$return, &quot;;
if ($seconds >=2) $return=&quot;$return $seconds seconds&quot;; if ($seconds ==1) $return=&quot;$return $seconds second&quot;;  $return=&quot;$return.&quot;;  return $return;  }
PHP comments <?php/* Initialize some variables using C style comments$a - contains a-coefficient$b - contains b-coefficient$x - value we are evaluating$y - result from evaluating equation */$a = 1; $b = 2; $x = 1;$y = $a * $x + $b;if ( $y < 5 )// C++ style comment, check if y<5{# Shell style comment, display something when y<5 echo &quot;Guess what?  y is less than 5!&quot;; }

More Related Content

PPTX
DODN2009 - Jump Start Silverlight
PPT
Pragmatics of Declarative Ajax
PPT
Flex_rest_optimization
PPTX
Lesson 1
PPT
Ajax to the Moon
PDF
20150812 4시간만에 따라해보는 windows 10 앱 개발
PPT
Web II - 01 - Introduction to server-side development
PDF
Laravel mail example how to send an email using markdown template in laravel 8
DODN2009 - Jump Start Silverlight
Pragmatics of Declarative Ajax
Flex_rest_optimization
Lesson 1
Ajax to the Moon
20150812 4시간만에 따라해보는 windows 10 앱 개발
Web II - 01 - Introduction to server-side development
Laravel mail example how to send an email using markdown template in laravel 8

What's hot (20)

PDF
Enterprising JavaFX
PDF
Create a meteor chat app in 30 minutes
PPT
Flex in portal
ZIP
Looking into HTML5
PPT
Joomla security nuggets
PPTX
Behat - Drupal South 2018
PPT
Your First ASP_Net project part 1
PPT
Widget Summit 2008
PPT
CIS 451: Introduction to ASP.NET
PPT
Internet Explorer 8 for Developers by Christian Thilmany
PDF
Intro to WebSockets (in Java)
PPT
High Performance Ajax Applications
PPT
Pragmatic Parallels: Java and JavaScript
PDF
Installing php 7.4 Nginx Laravel 7.x on Centos 8
PDF
HTML5 for PHP Developers - IPC
PPTX
Fast by Default
PDF
Alt tab - better apex tabs
PDF
Get started with meteor | designveloper software agency meteor prime partner
PDF
Intro to mobile web application development
PDF
How to deploy laravel application on aws ec2
Enterprising JavaFX
Create a meteor chat app in 30 minutes
Flex in portal
Looking into HTML5
Joomla security nuggets
Behat - Drupal South 2018
Your First ASP_Net project part 1
Widget Summit 2008
CIS 451: Introduction to ASP.NET
Internet Explorer 8 for Developers by Christian Thilmany
Intro to WebSockets (in Java)
High Performance Ajax Applications
Pragmatic Parallels: Java and JavaScript
Installing php 7.4 Nginx Laravel 7.x on Centos 8
HTML5 for PHP Developers - IPC
Fast by Default
Alt tab - better apex tabs
Get started with meteor | designveloper software agency meteor prime partner
Intro to mobile web application development
How to deploy laravel application on aws ec2
Ad

Similar to Php (20)

PPT
course slides -- powerpoint
PPT
PHP Presentation
PPT
Introduction To Lamp
PPT
PPT
PHP Presentation
PPT
Php intro
PPT
Justmeans power point
PPT
Justmeans power point
PPT
Justmeans power point
PPT
Justmeans power point
PPT
Justmeans power point
PPT
Justmeans power point
PPT
Justmeans power point
PPT
Justmeans power point
PPT
Php Crash Course
PPT
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PPT
PPT
Control Structures In Php 2
PPT
PPT
Dynamic Web Pages Ch 1 V1.0
course slides -- powerpoint
PHP Presentation
Introduction To Lamp
PHP Presentation
Php intro
Justmeans power point
Justmeans power point
Justmeans power point
Justmeans power point
Justmeans power point
Justmeans power point
Justmeans power point
Justmeans power point
Php Crash Course
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
Control Structures In Php 2
Dynamic Web Pages Ch 1 V1.0
Ad

More from Mindtree (6)

PPT
Apache
PPT
Mysql
PPT
Linux
DOC
Arjam[1]
DOC
Arjam[1]
DOC
Arjam[1]
Apache
Mysql
Linux
Arjam[1]
Arjam[1]
Arjam[1]

Recently uploaded (20)

PDF
Pre independence Education in Inndia.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
master seminar digital applications in india
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
RMMM.pdf make it easy to upload and study
PPTX
Cell Types and Its function , kingdom of life
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Basic Mud Logging Guide for educational purpose
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
01-Introduction-to-Information-Management.pdf
Pre independence Education in Inndia.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPH.pptx obstetrics and gynecology in nursing
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
master seminar digital applications in india
Anesthesia in Laparoscopic Surgery in India
Abdominal Access Techniques with Prof. Dr. R K Mishra
FourierSeries-QuestionsWithAnswers(Part-A).pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
RMMM.pdf make it easy to upload and study
Cell Types and Its function , kingdom of life
Microbial disease of the cardiovascular and lymphatic systems
Supply Chain Operations Speaking Notes -ICLT Program
TR - Agricultural Crops Production NC III.pdf
Insiders guide to clinical Medicine.pdf
Complications of Minimal Access Surgery at WLH
Basic Mud Logging Guide for educational purpose
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
01-Introduction-to-Information-Management.pdf

Php

  • 1. 10 th planet Technologies ArjunRaj.d Php Install Uninstall Setup Configure Samples
  • 2. Installation, setup and configure PHP-Fusion download PHP-Fusion After unpacking the file The file readme-xx.HTML (indifferent language versions) stipulates the conditions for using PHP-Fusion (GNU - GPL) and the main instructions for the installation. the installation process by making a new MySQL database or by getting your provider to create one for you on the web server where your web-page will reside.
  • 3. copy all the files in the folder php-files to the root of the web server (by using a FTP-program such as CuteFTP or SmartFTP). set the permissions on a number of files and folders for the installation process to run smoothly The README files refer to the CHMOD command
  • 4. to ‘change the mode’ of the file, which is simply setting the file or folder permissions. these permissions either through your FTP-program or via the interface solution provided by your service provider. Readme-xx.html
  • 5. set the permissions1: The folders and files: administration/db_backups/ · images/ · images/imagelist.js · images/articles/ · images/avatars/ · images/news/
  • 6. · images/news_cats/ · images/photoalbum/ · images/photoalbum/submissions/ · forum/attachments/ · config.php - should be set to 777. code 777 means, that these folders should have the permissions:
  • 7. Installing PHP-Fusion step 1 Here you start out by choosing the language in which the dialogue of the installation process will proceed (the number of languages will grow rapidly in the near future). In this example we choose ‘English’. If you choose another language, the language of the setup screen will change. But here we just fill out the fields in the form – like this – and click ‘ Next’: PHPFusion_setup_1.PNG
  • 8. the language of the setup screen
  • 13. Step 6 CONGRATULATION!!! You’ve already successfully installed PHP-Fusion.Enjoy using PHP
  • 14. <? print(&quot;Hello World&quot;) ?> <?=&quot;Hello World&quot;?>
  • 15. Set background color from a drop-down list. <!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;> <html> <head> <title>Change background color from a drop-down list</title> <script> <!-- function changeColor(newColor) { DHTMLSafe=aeObjects[&quot;test&quot;];
  • 16. DHTMLSafe.DOM.body.style.backgroundColor = newColor; document.all.colorPicker.selectedIndex = 0; }//--> </script> </head>
  • 17. </head> <body> <% Session(&quot;userid&quot;) = &quot;1&quot; imageurl = &quot;/images&quot; + Session(&quot;userid&quot;) + &quot;/&quot; imagepath = &quot;c:Inetpubwwwrootimages&quot; + Session(&quot;userid&quot;) %>
  • 18. <%Set ae= Server.CreateObject(&quot;CFDEV.Activedit&quot;) ae.AllowEditSource=true ae.QuickFonts=&quot;Arial, Courier&quot; ae.DefaultFont=&quot;10pt Arial&quot; ae.BaseURL=&quot;http://localhost&quot; ae.Border=&quot;1px solid black&quot; ae.BreakOnEnter=true
  • 19. ae.Width=&quot;50%&quot; ae.Height=&quot;50%&quot; ae.Name=&quot;test&quot; ae.Inc=&quot;inc/&quot; ae.ImagePath=imagepath ae.ImageURL=imageurl ae.AllowUpload=true
  • 21. <form action=&quot;action.asp&quot; method=&quot;post&quot;> <select id=&quot;colorPicker&quot; onChange=&quot;changeColor(this.options[this.selectedIndex].value)&quot;> <option>Background Color <option value=&quot;0000FF&quot;>Blue <option value=&quot;FF0000&quot;>Red <option value=&quot;00FF00&quot;>Green
  • 22. <option value=&quot;000000&quot;>Black </select> <% ae.Write() %> <% ae.Name=&quot;test2&quot; ae.Write() %> <INPUT TYPE=&quot;SUBMIT&quot;></form> </body> </html>
  • 23. Print the current date using php's date formatting function date September 3rd, 2002 <? print date(&quot;F jS, Y&quot;); ?> mm/dd/yyyy <? print date(&quot;m/j/Y&quot;); ?> mm/dd/yy <? print date(&quot;m/j/y&quot;); ?>
  • 24. Format the current time with the php date function h:mm:ss (24 hour) <? print date(&quot;H:i:s&quot;); ?> h:mm:ss (12 hour) <? print date(&quot;h:i:s&quot;); ?> h:mm:ss (AM/PM) <? print date(&quot;h:i:s A&quot;); ?>
  • 25. Print out environment variables. Place the following in a file named variables.inc in the current directory. <?php // Print Environment Variables echo &quot;<b>Environment Variables from $HTTP_ENV_VARS</b><br><br>&quot;; reset($HTTP_ENV_VARS); while (list ($key, $val) = each ($HTTP_ENV_VARS)) { print $key . &quot; = &quot; . $val . &quot;<br>&quot;; }
  • 26. // Print GET Variables echo &quot;<br>&quot;; echo &quot;<b>GET Variables from $HTTP_GET_VARS</b><br><br>&quot;; reset($HTTP_GET_VARS); while (list ($key, $val) = each ($HTTP_GET_VARS)) { print $key . &quot; = &quot; . $val . &quot;<br>&quot;; }// Print POST Variables echo &quot;<br>&quot;;
  • 27. echo &quot;<b>POST Variables from $HTTP_POST_VARS</b><br><br>&quot;; reset($HTTP_POST_VARS); while (list ($key, $val) = each ($HTTP_POST_VARS)) { print $key . &quot; = &quot; . $val . &quot;<br>&quot;; }// Print COOKIE Variables echo &quot;<br>&quot;;
  • 28. echo &quot;<b>COOKIE Variables from $HTTP_COOKIE_VARS</b><br><br>&quot;; reset($HTTP_COOKIE_VARS); while (list ($key, $val) = each ($HTTP_COOKIE_VARS)) { print $key . &quot; = &quot; . $val . &quot;<br>&quot;; }
  • 29. // Print SESSION Variables echo &quot;<br>&quot;; echo &quot;<b>SESSION Variables from $HTTP_SESSION_VARS</b><br><br>&quot;; reset($HTTP_SESSION_VARS); while (list ($key, $val) = each ($HTTP_SESSION_VARS)) { print $key . &quot; = &quot; . $val . &quot;<br>&quot;; }?>
  • 30. Call the file with the following at any point in your page where you would like the variables output. <?php require(&quot;variables.inc&quot;); ?>
  • 31. Convert common user input to a boolean <?php /* The stringToBoolean function accepts a string and returns a boolean. This is a nice function to handle user input for a boolean, which may be 0, false, False, no or No, for example.*/function stringToBoolean($str) { $str = trim(strtolower($str)); if ($str == &quot;0&quot; || $str == &quot;false&quot; || $str == &quot;no&quot;) { return 0; }else { return 1 } }
  • 32. // Code to test stringToBoolean() $strings = array(&quot;false&quot;,&quot;no&quot;,&quot;test&quot;,&quot;string&quot;,&quot;False&quot;,0); foreach($strings as $string) { print &quot;$string : &quot;; print stringToBoolean($string)? &quot;True&quot;:&quot;False&quot;; print &quot;<br> &quot;;}?>
  • 33. Handling amounts of data to be divided into several pages... <?php /* NAME 'list_from_db.inc' //Lists records from DB - line by line with href/link to a 'detail-page' // USED IN Page for showing a list of news from your database. // The scrict handles amounts that has to be divided into several &quot;pages&quot;, // and builds links to all pages - including PRIOR and NEXT./// ADJUSTMENTS to be made before use:
  • 34. $curr_page - points to &quot;CURRENT&quot; page AND MUST BE SET TO 1 IN THE CALLING PAGE // ex.: in index.php ...<a href=news.php?ID=1</a>in news.php <?php $curr_page=$_GET['ID']; ?> // $max_page - max number of listings (newslines) you want on your/each page details.php - this is the page for showing details in the newsline. Adjust the name...myself.php - this is the page where this script is included. Adjust the name... table etc - adjust the names to fit your DB connection - adjust this to fit your DB
  • 35. mysql_connect('localhost', 'user_name', 'pass_word'); mysql_select_db('your_db'); //adjust these variables to fit your page //$max_page = 20; /* set the number that fits your case */ $query = &quot;SELECT * FROM tableWHERE ...ORDER BY ...&quot;;$result = mysql_query($query); $max_rows = mysql_num_rows($result);
  • 36. // Did we find any data? if ($max_rows >0) { // need to be shure if we have a full page - or more... $max_pages = intval($max_rows / $max_page) +1;//$max_pages = intval($max_pages)+1; $row_num = $max_page * ($curr_page-1); $num_list = 1;$num_lines = 0; $max_lines = $max_page + 5;
  • 37. pointer of tablerow works from fra 0 til max_rows -1//while ($row_num <= $max_rows-1) { mysql_data_seek($result,$row_num); $row = mysql_fetch_array($result); if ($num_list <= $max_page) { $row_num++; $year = intval(substr($row[3],2,2)); $month = intval(substr($row[3],5,2)); $day = intval(substr($row[3],8,2)); row[1] keeps the headline for the record
  • 38. print(&quot;<TABLE BORDER=0>&quot;); print(&quot;<TR>&quot;); echo &quot;<TD width=5><font face= Verdana, sans-serif size=2>-</TD></font>&quot;;echo &quot;<TD width=365><font face= Verdana, sans-serif size=2><a href=&quot;details.php?ID=$row[0]>$row[1] </a> - $day/$month-0$year</TD></font>&quot;; print(&quot;</TR>&quot;); print(&quot;</TABLE>&quot;);$num_lines++; $num_list++; } else { break; } }
  • 39. if ($max_pages > 1) { Puts blank lines to adjust the &quot;page-info line&quot; on the same place each time //while ($num_lines < $max_lines) {echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;2&quot;><br></font>&quot;;$num_lines++; }Writes the page-info-line - and removes the LINK to &quot;current page&quot; //-----echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;2&quot;><br><br><b>&quot;;$prior = $curr_page - 1;$next = $curr_page + 1;
  • 40. if ($curr_page > 1) { echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;1&quot;> <a href=&quot;myself.php?ID=$prior>Prior </a></font>&quot;; } $page=1; while ($page <= $max_pages) {
  • 41. if ($max_pages > 1) { echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;1&quot; color=&quot;#999999&quot;> $page</font>&quot;; } } else {echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;1&quot; color=&quot;#000000&quot;> <a href=&quot;myself.php?ID=$page>$page</a></font>&quot;;}$page++; }
  • 42. if ($curr_page < $max_pages) { echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;1&quot;> <a href=&quot;myself.php?ID=$next> Next</a></font>&quot;; } } } else {
  • 43. echo &quot;<font face=&quot;Verdana, sans-serif&quot; size=&quot;2&quot;>No data found</font>&quot;; }
  • 44. User to set the background color and text color <body bgcolor=<?=$_GET[&quot;bg&quot;]?> text=<?=$_GET[&quot;txt&quot;]?>><center><form method=&quot;GET&quot;> <input type=&quot;text&quot; value=&quot;Background Color&quot; name=&quot;bg&quot;> <input type=&quot;text&quot; value=&quot;Text Color&quot; name=&quot;txt&quot;> <input type=&quot;hidden&quot; value=1 name=done> <input type=&quot;submit&quot; value=&quot;Change&quot;> <input type=&quot;reset&quot; value=reset></form><?
  • 45. if (isset($_GET[&quot;done&quot;])) {if ($_GET[&quot;bg&quot;]==&quot;YOUR SPECIFIC BACKGROUND COLOR&quot;) {if ($_GET[&quot;txt&quot;]==&quot;YOUR SPECIFIC TEXT COLOR&quot;) { echo &quot;YOUR TEXT IF COLORS ARE USED&quot;; } else {echo &quot;You are using $_GET[bg] for your background color and $_GET[txt] for your text color&quot;; }
  • 46. }else {echo &quot;You are using $_GET[bg] for your background color and $_GET[txt] for your text color&quot;; }}else { echo &quot;<font color=white>Choose something</font>&quot;; } ?>
  • 47. <TABLE cellSpacing=1 cellPadding=2 bgColor=black border=0> <TR bgColor=white> <TD>First</TD> <TD>Last</TD> <TD>Email<TD> </TR> </TABLE> <?
  • 48. mysql_connect(&quot;localhost&quot;, &quot;db user&quot;, &quot;db pass&quot;)or die(&quot;DB CONNECT ERROR: &quot; . mysql_error()); mysql_select_db(&quot;db name&quot;) or die(&quot;DB SELECT ERROR: &quot; . mysql_error()); $query = &quot;SELECT fname, lname, email FROM table ORDER BY lname&quot;; $result = mysql_query($query) or die(&quot;DB SELECT ERROR: &quot; . mysql_error());
  • 49. while($row = mysql_fetch_array($result)) {$lname = $row['lname'];$fname = $row['fname'];$email = $row['email']; ?><TR bgColor=white><TD><?=$fname?></TD><TD><?=$lname?></TD><TD><?=$email?><TD></TR> </TABLE> <?
  • 50. Time left using unix time stamp function time_left($integer) { $seconds=$integer; if ($seconds/60 >=1) { $minutes=floor($seconds/60); if ($minutes/60 >= 1) { # Hours $hours=floor($minutes/60); if ($hours/24 >= 1) { #days $days=floor($hours/24); if ($days/7 >=1){ #weeks
  • 51. $weeks=floor($days/7); if ($weeks>=2) $return=&quot;$weeks Weeks&quot;; else $return=&quot;$weeks Week&quot;; } #end of weeks $days=$days-(floor($days/7))*7; if ($weeks>=1 && $days >=1) $return=&quot;$return, &quot;; if ($days >=2) $return=&quot;$return $days days&quot;; if ($days ==1) $return=&quot;$return $days day&quot;; } #end of days
  • 52. $hours=$hours-(floor($hours/24))*24; if ($days>=1 && $hours >=1) $return=&quot;$return, &quot;; if ($hours >=2) $return=&quot;$return $hours hours&quot;; if ($hours ==1) $return=&quot;$return $hourshour&quot;; } #end of Hours
  • 53. $minutes=$minutes-(floor($minutes/60))*60; if ($hours>=1 && $minutes >=1) $return=&quot;$return, &quot;; if ($minutes >=2) $return=&quot;$return $minutes minutes&quot;; if ($minutes ==1) $return=&quot;$return $minutes minute&quot;; } #end of minutes $seconds=$integer-(floor($integer/60))*60; if ($minutes>=1 && $seconds >=1) $return=&quot;$return, &quot;;
  • 54. if ($seconds >=2) $return=&quot;$return $seconds seconds&quot;; if ($seconds ==1) $return=&quot;$return $seconds second&quot;; $return=&quot;$return.&quot;; return $return; }
  • 55. PHP comments <?php/* Initialize some variables using C style comments$a - contains a-coefficient$b - contains b-coefficient$x - value we are evaluating$y - result from evaluating equation */$a = 1; $b = 2; $x = 1;$y = $a * $x + $b;if ( $y < 5 )// C++ style comment, check if y<5{# Shell style comment, display something when y<5 echo &quot;Guess what? y is less than 5!&quot;; }