Download presentation
Presentation is loading. Please wait.
1
Introduction to php Chapter 1 ACSG 550
2
What we will be doing… Developing full-service websites with – dynamic content – support for user interaction – client and server-side processing – underlying databases We are using php and mysql
3
php A scripting language that supports server-side processing It’s a full language in its own right – Variables – Control structures – Objects We embed it into our html pages – Dynamic content – Form processing – Database processing
4
Where is php? On our web servers – csmaster – cs1 You can also download it from www.php.net and configure it for use on your own computer www.php.net In class for now, we’ll use csmaster
5
Example files freight.html freight.php orderform.html processorder.php
6
html forms Item Quantity Tires Oil Spark Plugs How did you find Bob's? I'm a regular customer TV advertising Phone directory Word of mouth orderform.html
7
processororder.php – Part 1 <?php // create short variable names $tireqty = $_POST['tireqty']; $oilqty = $_POST['oilqty']; $sparkqty = $_POST['sparkqty']; $find = $_POST['find']; ?>
8
processororder.php – Part 2 Bob's Auto Parts - Order Results Bob's Auto Parts Order Results
9
processororder.php – Part 3 <?php echo ' Order processed at '; echo date('H:i, jS F'); echo ' '; echo ' Your order is as follows: '; $totalqty = 0; $totalqty = $tireqty + $oilqty + $sparkqty; echo 'Items ordered: '.$totalqty.' '; if( $totalqty == 0) { echo 'You did not order anything on the previous page! '; } else { if ( $tireqty>0 ) echo $tireqty.' tires '; if ( $oilqty>0 ) echo $oilqty.' bottles of oil '; if ( $sparkqty>0 ) echo $sparkqty.' spark plugs '; }
10
processororder.php – Part 4 $totalamount = 0.00; define('TIREPRICE', 100); define('OILPRICE', 10); define('SPARKPRICE', 4); $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE; echo 'Subtotal: $'.number_format($totalamount,2).' '; $taxrate = 0.10; // local sales tax is 10% $totalamount = $totalamount * (1 + $taxrate); echo 'Total including tax: $'.number_format($totalamount,2).' '; if($find == 'a') echo ' Regular customer. '; elseif($find == 'b') echo ' Customer referred by TV advert. '; elseif($find == 'c') echo ' Customer referred by phone directory. '; elseif($find == 'd') echo ' Customer referred by word of mouth. '; else echo ' We do not know how this customer found us. '; ?>
11
freight.php Distance Cost <? $distance = 50; while ($distance <= 250 ) { echo " \n $distance \n"; echo " ". $distance / 5 " \n \n"; $distance += 50; } ?>
12
Assignment Lab 1 hand-out HW – read Chapter 1 Next week’s class is online – Check that you can access Blackboard – Assignments will be available in Blackboard starting Friday The topic of these assignments is the fundamentals of php, as introduced in Chapter 1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.