CICS 515 b Internet Programming Week 2. Mike Feeley
|
|
- May Pope
- 5 years ago
- Views:
Transcription
1 CICS 515 b Internet Programming Week 2 Mike Feeley 1
2 Software infrastructure stuff MySQL and PHP store files in public_html run on remote.mss.icics.ubc.ca access as see wiki for configuration instructions and experience from previous years Eclipse for HTML / JavaScript editing and debugging get the full build install current ATF build - ( download JSLint - patched.js&use_mirror=umn - and set Ecplise AFT preferences to use it 2
3 Reading PHP Review
4 A Sample Application 4
5 Description simple student database student ID is unique nine-digit number name is a 30 character string store the student database in MySql design a web page that displays the complete list of students allows new students to be added allows students to be deleted allows student names to be changed its in this weeks code base 5
6 Database MySQL online documentation MySQL on command line ~% /usr/local/mysql/bin/mysql -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 420 Server version: MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> use feeley_database; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> 6
7 list tables mysql> show tables; Tables_in_feeley_database student row in set (0.00 sec) mysql> show a table s schema mysql> describe student; Field Type Null Key Default Extra sid int(11) NO PRI name varchar(32) YES NULL rows in set (0.36 sec) mysql> 7
8 delete the table mysql> drop table student; Query OK, 0 rows affected (0.19 sec) mysql> show tables; Empty set (0.00 sec) adding the student table schema mysql> CREATE TABLE student ( -> sid INT NOT NULL, -> name VARCHAR(30), -> PRIMARY KEY (sid)); Query OK, 0 rows affected (0.02 sec) mysql> DESCRIBE student; Field Type Null Key Default Extra sid int(11) NO PRI name varchar(30) YES NULL rows in set (0.02 sec) 8
9 Introduction to PHP PHP hypertext preprocessor script embedded in an HTML document script is executed in web server when document is requested by client script inserts HTML code to replace itself in the document server sends resulting pure HTML document to client browser basic syntax foo.php: <html> <body> <?php echo "Hello.";?> </body> </html> debugging nightmear any bug in script and sever my just send blank document build, test incrementally 9
10 variables names start with $ replaced within strings (rules a bit complicated) - foo.$var. foo or foo$var foo or foo${varfoo arrays are associative - $a[2] or $a[ cat ] <html> <body> <?php $sid[0] = 10; $name[0] = "First Student"; $sid[1] = 20; $name[1] = "Second Student"; echo "<table border=2>"; echo "<tr><td>".$sid[0]."</td><td>".$name[0]."</td></tr>"; echo "<tr><td>".$sid[1]."</td><td>".$name[1]."</td></tr>"; echo "</table>";?> </body> </html> 10
11 other stuff is like C (which is like Java) for loops, while loops, function etc. <html> <body> <?php $sid[0] = 10; $name[0] = "First Student"; $sid[1] = 20; $name[1] = "Second Student"; echo "<table border=2>"; for ($i=0; $i<2; $i++) { echo "<tr><td>".$sid[$i]."</td><td>".$name[$i]."</td></tr>"; echo "</table>";?> </body> </html> 11
12 PHP and MySQL online documentation dbconfig.php and opendb.php <?php $dbhost = ':/.autofs/homes/ubccshome/f/feeley/cics515/mysql/var/mysql.sock'; $dbuser = 'feeley'; $dbpass = 'feeley'; $dbname = 'feeley_database';?> <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname);?> 12
13 MySql Configuration file MySqld is configured by.my.sql file in your root directory PHP attaches to mysql using a socket file you name the file in your dbconfig.php <?php $dbhost = ':/.autofs/homes/ubccshome/f/feeley/cics515/mysql/var/mysql.sock';... You configure MySqld to choose an unique port to use this socket file [mysqld] port = 8743 socket = /.autofs/homes/ubccshome/f/feeley/cics515/mysql/var/mysql.sock datadir = /.autofs/homes/ubccshome/f/feeley/cics515/mysql/var Also see the Wiki 13
14 querying db and displaying results liststudents.php: <html> <body> <?php include 'dbconfig.php'; include 'opendb.php'; $rows = mysql_query ("SELECT * FROM student ORDER BY sid"); echo "<table border=2>\n"; echo "<tr><td><b>sid</b></td><td><b>name</b></td></tr>\n"; while ($row = mysql_fetch_assoc ($rows)) echo "<tr><td>".$row['sid']."</td><td>".$row['name']."</td></tr>\n"; echo "</table>\n"; mysql_close ();?> </body> </html> 14
15 the result web server Apache database MySql <html> <body> <?php include 'dbconfig.php'; include 'opendb.php'; $rows = mysql_query ("SELECT * FROM student ORDER BY sid"); echo "<table border=2>\n"; echo "<tr><td><b>sid</b></td><td><b>name</b></td></tr>\n"; while ($row = mysql_fetch_assoc ($rows)) echo "<tr><td>".$row['sid']."</td><td>".$row['name']."</td></tr>\n"; echo "</table>\n"; mysql_close ();?> </body> </html> mysql> select * from student order by sid; sid name country First Student NULL 20 Second Student NULL rows in set (0.04 sec) web browser IE, Safari, Firefox, etc. <html> <body> <table border=2> <tr><td><b>sid</b></td><td><b>name</b></td></tr> <tr><td>10</td><td>first Student</td></tr> <tr><td>20</td><td>second Student</td></tr> </table> </body> </html> 15
16 Sending updates back to the database when a form is submitted browser sends name and value of every input element back to web server either using the post HTML message - send input values in HTML, to a specified URL or the get HTML messages - request a specified URL with input values appended to it declaring form method and action <form method=? action=? > method is post or get - use get for idempotent operations operations where performing once is the same as performing more than once - otherwise use post action is URL that browser posts to or gets from in PHP $_POST[ name ] or $_GET[ name ] value of named input element 16
17 example simpleform.html: <html> <body> <form method="post" action="simplepost.php"> <input name="p1" type="text" size="20"> <input name="p2" type="number"> <input name="submit" value="post" type="submit"> </form> <form method="get" action="simpleget.php"> <input name="p1" type="text" size="20"> <input name="p2" type="number"> <input name="submit" value="get" type="submit"> </form> </body> </html> simpleget.php: <html> <body> <?php $p1 = $_GET['p1']; $p2 = $_GET['p2']; echo "<table>\n"; echo "<tr><td>p1</td><td>$p1</td></tr>"; echo "<tr><td>p2</td><td>$p2</td></tr>"; echo "</table>";?> </body> </html> simplepost.php: <html> <body> <?php $p1 = $_POST['p1']; $p2 = $_POST['p2']; echo "<table>\n"; echo "<tr><td>p1</td><td>$p1</td></tr>"; echo "<tr><td>p2</td><td>$p2</td></tr>"; echo "</table>";?> </body> </html> 17
18 in action 18
19 Combining the HTML form and PHP processing generate all HTML dynamically using PHP submit action is current form _SERVER[ PHP_SELF ] use hidden input on form to see if anything submitted yet <html> <body> <?php echo "<form method='post' action=${_server['php_self']>"; echo " <input name='action' type='hidden' value='submitted'>"; echo " <input name='p1' type='text' size='20'>"; echo " <input name='p2' type='number'>"; echo " <input name='submit' value='post' type='submit'>"; echo "</form>"; if (isset($_post['action']) && $_POST['action']=='submitted') { $p1 = $_POST['p1']; $p2 = $_POST['p2']; echo "<table>\n"; echo "<tr><td>p1</td><td>$p1</td></tr>"; echo "<tr><td>p2</td><td>$p2</td></tr>"; echo "</table>";?> </body> </html> 19
20 Your turn... build combo form for access/insert to student database lists all student in the database (SID and NAME) has an input form for a new SID and NAME and a submit button INSERT inserts new student into database when submitted don t look at the next slide 20
21 if (isset($_post['action']) && $_POST['action']=='submitted') { $sid = $_POST['sid']; $name = $_POST['name']; if (isset($_post['insert'])) mysql_query ("INSERT INTO student(sid,name) VALUES($sid,'$name')"); $rows = mysql_query ("SELECT * FROM student ORDER BY sid"); echo "<table border=2>\n"; echo "<tr><td><b>sid</b></td><td><b>name</b></td></tr>\n"; while ($row = mysql_fetch_assoc ($rows)) echo "<tr><td>".$row['sid']."</td><td>".$row['name']."</td></tr>\n"; echo "</table>\n"; echo "<form method='post' action=${_server['php_self']>"; echo "<table border=1>"; echo "<tr><td> <td align=center>sid<td align=center>name"; echo "<input type='hidden' name='action' value='submitted'>"; echo "<tr><td><input type='submit' name='insert' value='insert'>"; echo "<td><input name='sid' type='text' size='10'>"; echo "<td><input name='name' type='text' size='30'>"; echo "</table>"; echo "</form>"; 21
22 22
23 An insert, delete and update form <html> <body> <?php include 'dbconfig.php'; include 'opendb.php'; if (isset($_post['action']) && $_POST['action']=='submitted') { $selected = $_POST['selected']; $sid = $_POST['sid']; $name = $_POST['name']; $isid = $_POST['iSid']; $iname = $_POST['iName']; if (isset($_post['update'])) { foreach ($selected as $i) mysql_query ("UPDATE student set name='".$name[$i]."' WHERE sid=".$sid[$i]); else if (isset($_post['insert'])) { mysql_query ("INSERT INTO student(sid,name) VALUES ($isid,'$iname')"); else if (isset($_post['delete'])) { foreach ($selected as $i) mysql_query ("DELETE FROM student WHERE sid=".$sid[$i]); echo "<form method='post' action=${_server['php_self']>\n"; echo "<table border=1>\n"; echo "<tr><td> </td><td><b>sid</b></td>"; echo "<td><b>name</b></td></tr>\n"; $rows = mysql_query ("SELECT sid, name FROM student ORDER BY sid"); for ($i=0; $i<mysql_numrows($rows); $i++) { $sid = mysql_result ($rows, $i, 'sid'); $name = mysql_result ($rows, $i, 'name'); echo "<tr>\n"; echo "<td><input name='selected[]' type='checkbox' value='$i'>\n"; echo "<td>$sid<input type='hidden' name='sid[]' value='$sid'>\n"; echo "<td><input name='name[]' type='text' size='30' value='$name'>\n"; echo "</tr>\n"; echo "<input type='hidden' name='action' value='submitted'>\n"; echo "<tr><td><input type='submit' name='insert' value='insert'>\n"; echo "<td><input name='isid' type='text' size='10'>\n"; echo "<td><input name='iname' type='text' size='30'>\n"; echo "</table>\n"; echo "<input type='submit' name='update' value='update'>\n"; echo "<input type='submit' name='delete' value='delete'>\n"; echo "</form>\n"; mysql_close ();?> </body> </html> 23
24 Insert, delete and update the form in HTML (generated by the PHP page) <html> <body> <form method='post' action=/~feeley/515-0/enterstudents.php> <table border=1> <tr><td> </td><td><b>sid</b></td><td><b>name</b></td></tr> <tr> <td><input name='selected[]' type='checkbox' value='0'> <td>10<input type='hidden' name='sid[]' value='10'> <td><input name='name[]' type='text' size='30' value='first Student'> </tr> <tr> <td><input name='selected[]' type='checkbox' value='1'> <td>20<input type='hidden' name='sid[]' value='20'> <td><input name='name[]' type='text' size='30' value='second Student'> </tr> <input type='hidden' name='action' value='submitted'> <tr><td><input type='submit' name='insert' value='insert'> <td><input name='isid' type='text' size='10'> <td><input name='iname' type='text' size='30'> </table> <input type='submit' name='update' value='update'> <input type='submit' name='delete' value='delete'> </form> </body> </html> 24
25 the PHP that produces the form echo "<form method='post' action=${_server['php_self']>\n"; echo "<table border=1>\n"; echo "<tr><td> </td><td><b>sid</b></td>"; echo "<td><b>name</b></td></tr>\n"; $rows = mysql_query ("SELECT sid, name FROM student ORDER BY sid"); for ($i=0; $i<mysql_numrows($rows); $i++) { $sid = mysql_result ($rows, $i, 'sid'); $name = mysql_result ($rows, $i, 'name'); echo "<tr>\n"; echo "<td><input name='selected[]' type='checkbox' value='$i'>\n"; echo "<td>$sid<input type='hidden' name='sid[]' value='$sid'>\n"; echo "<td><input name='name[]' type='text' size='30' value='$name'>\n"; echo "</tr>\n"; echo "<input type='hidden' name='action' value='submitted'>\n"; echo "<tr><td><input type='submit' name='insert' value='insert'>\n"; echo "<td><input name='isid' type='text' size='10'>\n"; echo "<td><input name='iname' type='text' size='30'>\n"; echo "</table>\n"; echo "<input type='submit' name='update' value='update'>\n"; echo "<input type='submit' name='delete' value='delete'>\n"; echo "</form>\n"; 25
26 the PHP that handles submits if (isset($_post['action']) && $_POST['action']=='submitted') { $selected = $_POST['selected']; $sid = $_POST['sid']; $name = $_POST['name']; $isid = $_POST['iSid']; $iname = $_POST['iName']; if (isset($_post['update'])) { foreach ($selected as $i) mysql_query ("UPDATE student SET name='".$name[$i]."' WHERE sid=".$sid[$i]); else if (isset($_post['insert'])) { mysql_query ("INSERT INTO student(sid,name) VALUES ($isid,'$iname')"); else if (isset($_post['delete'])) { foreach ($selected as $i) mysql_query ("DELETE FROM student WHERE sid=".$sid[$i]); 26
27 Understanding post (using get) when a submit button causes form inputs to be posted every input is added to the POST area of the HTTP submission to the web server for radio buttons, checkboxes and buttons, their name/value appear only if checked/pressed to understand, lets convert form to GET instead of POST change all $_POST to $_GET and convert form methods to get now everything previously sent in the POST area is appended to the URL on submit if the user selects the line with SID 10 and presses update here is the URL send to web server (formatted to make it easier to read) enterstudents.php? sid[]=10& name[]=first+student& sid[]=20& name[]=second+student& selected[]=0& action=submitted& isid=& iname=& update=update 27
28 Functions you can define functions (and even store them externally) function max ($arg0, $arg1) { if ($arg0>$arg1) return $arg0; else return $arg1; e.g., put standard stuff about students in one place studentlib.php: <?php function getstudents () { return mysql_query ("SELECT sid, name FROM student ORDER BY sid"); function insertstudent ($sid, $name) { mysql_query ("INSERT INTO student(sid,name) VALUES ($sid,'$name')"); function updatestudent ($sid, $name) { mysql_query ("UPDATE student SET name='$name' WHERE sid=$sid"); function deletestudent ($sid) { mysql_query ("DELETE FROM student WHERE sid='$sid'");?> 28
29 then enterstudents.php becomes... if (isset($_post['update'])) { foreach ($selected as $i) updatestudent ($sid[$i], $name[$i]); else if (isset($_post['insert'])) { insertstudent ($isid, $iname); else if (isset($_post['delete'])) { foreach ($selected as $i) deletestudent ($sid[$i]); echo "<form method='post' action=${_server['php_self']>\n"; echo "<table border=1>\n"; echo "<tr><td> </td><td><b>sid</b></td>"; echo "<td><b>name</b></td></tr>\n"; $rows = getstudents ();... 29
30 Functions and Variable Scope Variables have no declaration statement common to stripping languages --- less typing PHP is dynamically typed so no need to associate type in declaration Use-without-declare has some drawbacks if you misspell a variable... well, you ve created a new variable how can you differentiate local and global variables? for these reasons, some dynamically-typed languages do have variable declaration PHP s compromise to use a global variable inside of a function, it must be declared using global keyword $foo = "blah"; function a() { $foo = "blah blah"; echo $foo; a(); echo $foo; $foo = "blah"; function a() { global $foo; $foo = "blah blah"; echo $foo; a(); echo $foo; blah blah blah 30
31 Function Arguments Pass by value is the standard approach value is copied from actual argument to formal argument foo ($a, $b) { echo $a.$b; foo ($x, $y); Pass by reference add ampersand to either formal or actual argument pointer to value is copied from actual to formal argument fooref (&$a, &$b) { echo $a.$b; foo (&$x, &$y); fooref ($x, $y); 31
32 Handling errors PHP has exceptions with Java syntax this is what you should use for functions you write some functions fail by returning false this how mysql_*() functions fail you can test list this function updatestudent ($sid, $name) { $result = mysql_query ("UPDATE studentx SET name='$name' WHERE sid=$sid"); if (!$result) die ("updatestudent failed with db error: ".mysql_error()); or like this function updatestudent ($sid, $name) { mysql_query ("UPDATE studentx SET name='$name' WHERE sid=$sid") or die ("updatestudent failed with db error: ".mysql_error()); 32
33 even better, use exceptions studentlib.php: class StudentDBException extends Exception { function updatestudent ($sid, $name) { $result = mysql_query ("UPDATE student SET name='$name' WHERE sid=$sid"); if (!$result) throw new StudentDBException (mysql_error()); enterstudents.php: try { if (isset($_post['action']) && $_POST['action']=='submitted') { $selected = $_POST['selected']; $sid = $_POST['sid']; $name = $_POST['name']; $isid = $_POST['iSid']; $iname = $_POST['iName']; if (isset($_post['update'])) { foreach ($selected as $i) updatestudent ($sid[$i], $name[$i]);... echo "</form>\n"; catch (StudentDBException $e) { die ("Student database error: ".$e->getmessage()); mysql_close (); 33
34 JavaScript 34
35 JavaScript is not Java client-side scripting language program that runs in browser at client two ways to include it in HTML document embedded blah.html: <body> <script type="text/javascript"> document.write ("Hello from embedded JavaScript."); </script> </body> in separate file blah.html: <head> <script language="javascript" src="blah.js"></script> </head> blah.js: document.write ("Hello from separate file JavaScript.<br>"); 35
36 For example set select box when name changes... <script type="text/javacript"> function checkbox (row) { document.getelementbyid('checkbox'+row).checked = true; </script>... for ($i=0; $i<mysql_numrows($rows); $i++) { $sid = mysql_result ($rows, $i, 'sid'); $name = mysql_result ($rows, $i, 'name'); echo "<tr>\n"; echo "<td><input id='checkbox$i' "; echo "name='selected[]' type='checkbox' value='$i'>\n"; echo "<td>$sid<input type='hidden' name='sid[]' value='$sid'>\n"; echo "<td><input name='name[]' type='text' size='30' value='$name'"; echo "onchange='checkbox($i)'>\n"; echo "</tr>\n"; 36
37 or disable name input until select box is checked <script type="text/javascript"> function checkbox (row) { var box = document.getelementbyid('checkbox'+row); var name = document.getelementbyid('name'+row); name.disabled =!box.checked; </script>... echo "<td><input id='checkbox$i' "; echo "name='selected[]' type='checkbox' value='$i'"; echo " onchange='checkbox($i)'>\n"; echo "<td>$sid<input type='hidden' name='sid[]' value='$sid'>\n"; echo "<td><input id='name$i' name='name[]' type='text' size='30'"; echo " value='$name' disabled='true'>\n"; 37
38 Debugging JavaScript Firefox IE Disable script debugging in Internet Options, Tools, Advanced Safari defaults write com.apple.safari IncludeDebugMenu 1 Eclipse with ATF ( 38
39 Homework Assignment 1 on web page Today due a week Sunday Project finish UML and database schema today basic layout for artwork and styles etc. next week 39
CICS 515 a Internet Programming Week 3. Mike Feeley
CICS 515 a Internet Programming Week 3 Mike Feeley JavaScript JavaScript is not Java client-side scripting language program that runs in browser at client two ways to include it in HTML document embedded
More informationCOM1004 Web and Internet Technology
COM1004 Web and Internet Technology When a user submits a web form, how do we save the information to a database? How do we retrieve that data later? ID NAME EMAIL MESSAGE TIMESTAMP 1 Mike mike@dcs Hi
More informationOptions. Real SQL Programming 1. Stored Procedures. Embedded SQL
Real 1 Options We have seen only how SQL is used at the generic query interface an environment where we sit at a terminal and ask queries of a database. Reality is almost always different: conventional
More informationBy the end of this section of the practical, the students should be able to:
By the end of this section of the practical, the students should be able to: Connecting to a MySQL database in PHP with the mysql_connect() and mysql_select_db() functions Trapping and displaying database
More informationCICS 515 a Internet Programming Week 5. Mike Feeley
CICS 515 a Internet Programming Week 5 Mike Feeley Generic MySQL Select to XML in PHP input to PHP form using GET, we could also use POST (example later) $table = $_GET['table']; $fields = $_GET['fields']
More informationPHP Introduction. Some info on MySQL which we will cover in the next workshop...
PHP and MYSQL PHP Introduction PHP is a recursive acronym for PHP: Hypertext Preprocessor -- It is a widely-used open source general-purpose serverside scripting language that is especially suited for
More informationChapter4: HTML Table and Script page, HTML5 new forms. Asst. Prof. Dr. Supakit Nootyaskool Information Technology, KMITL
Chapter4: HTML Table and Script page, HTML5 new forms Asst. Prof. Dr. Supakit Nootyaskool Information Technology, KMITL Objective To know HTML5 creating a new style form. To understand HTML table benefits
More informationHTML Tables and Forms. Outline. Review. Review. Example Demo/ Walkthrough. CS 418/518 Web Programming Spring Tables to Display Data"
CS 418/518 Web Programming Spring 2014 HTML Tables and Forms Dr. Michele Weigle http://www.cs.odu.edu/~mweigle/cs418-s14/ Outline! Assigned Reading! Chapter 4 "Using Tables to Display Data"! Chapter 5
More informationPHP 5 if...else...elseif Statements
PHP 5 if...else...elseif Statements Conditional statements are used to perform different actions based on different conditions. PHP Conditional Statements Very often when you write code, you want to perform
More informationCreate Basic Databases and Integrate with a Website Lesson 3
Create Basic Databases and Integrate with a Website Lesson 3 Combining PHP and MySQL This lesson presumes you have covered the basics of PHP as well as working with MySQL. Now you re ready to make the
More informationWeb Programming. Based on Notes by D. Hollinger Also Java Network Programming and Distributed Computing, Chs.. 9,10 Also Online Java Tutorial, Sun.
Web Programming Based on Notes by D. Hollinger Also Java Network Programming and Distributed Computing, Chs.. 9,10 Also Online Java Tutorial, Sun. 1 World-Wide Wide Web (Tim Berners-Lee & Cailliau 92)
More informationDynamic Form Processing Tool Version 5.0 November 2014
Dynamic Form Processing Tool Version 5.0 November 2014 Need more help, watch the video! Interlogic Graphics & Marketing (719) 884-1137 This tool allows an ICWS administrator to create forms that will be
More informationUNIT-VI CREATING AND USING FORMS
UNIT-VI CREATING AND USING FORMS To create a fully functional web application, you need to be able to interact with your users. The common way to receive information from web users is through a form. Forms
More informationChapter 1 FORMS. SYS-ED/ Computer Education Techniques, Inc.
Chapter 1 FORMS SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: How to use forms and the related form types. Controls for interacting with forms. Menus and presenting users with
More informationPHP Tutorial 6(a) Using PHP with MySQL
Objectives After completing this tutorial, the student should have learned; The basic in calling MySQL from PHP How to display data from MySQL using PHP How to insert data into MySQL using PHP Faculty
More informationEXPERIMENT OBJECTIVE:
EXPERIMENT-1 1.1 To accept a number from one text field in the range of 0 to 999 and shows it in another text field in words. If the number is out of range, it should show out of range and if it is not
More informationCHAPTER 10. Connecting to Databases within PHP
CHAPTER 10 Connecting to Databases within PHP CHAPTER OBJECTIVES Get a connection to a MySQL database from within PHP Use a particular database Send a query to the database Parse the query results Check
More informationLecture 6: More Arrays & HTML Forms. CS 383 Web Development II Monday, February 12, 2018
Lecture 6: More Arrays & HTML Forms CS 383 Web Development II Monday, February 12, 2018 Lambdas You may have encountered a lambda (sometimes called anonymous functions) in other programming languages The
More informationLAMP Apps. Overview. Learning Outcomes: At the completion of the lab you should be able to:
LAMP Apps Overview This lab walks you through using Linux, Apache, MySQL and PHP (LAMP) to create simple, yet very powerful PHP applications connected to a MySQL database. For developers using Windows,
More informationHello everyone! Page 1. Your folder should look like this. To start with Run your XAMPP app and start your Apache and MySQL.
Hello everyone! Welcome to our PHP + MySQL (Easy to learn) E.T.L. free online course Hope you have installed your XAMPP? And you have created your forms inside the studio file in the htdocs folder using
More informationHyperlinks, Tables, Forms and Frameworks
Hyperlinks, Tables, Forms and Frameworks Web Authoring and Design Benjamin Kenwright Outline Review Previous Material HTML Tables, Forms and Frameworks Summary Review/Discussion Email? Did everyone get
More informationCGI Programming. What is "CGI"?
CGI Programming What is "CGI"? Common Gateway Interface A means of running an executable program via the Web. CGI is not a Perl-specific concept. Almost any language can produce CGI programs even C++ (gasp!!)
More informationthe Data Drive IN THIS CHAPTER Good Things Come in Free Packages
c h a p t e r 7 Let the Data Drive IN THIS CHAPTER Good Things Come in Free Packages New Functions Installing MySQL Setting up a Simple Database Basic SQL Queries Putting Content into a Database Using
More informationServer-Side Web Programming: Python (Part 1) Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University
Server-Side Web Programming: Python (Part 1) Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University 1 Objectives You will learn about Server-side web programming in Python Common Gateway Interface
More informationIslamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM Advanced Internet Technology Lab.
Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 5049 Advanced Internet Technology Lab Lab # 1 Eng. Haneen El-masry February, 2015 Objective To be familiar with
More informationSpring 2014 Interim. HTML forms
HTML forms Forms are used very often when the user needs to provide information to the web server: Entering keywords in a search box Placing an order Subscribing to a mailing list Posting a comment Filling
More informationUSQ/CSC2406 Web Publishing
USQ/CSC2406 Web Publishing Lecture 4: HTML Forms, Server & CGI Scripts Tralvex (Rex) Yeap 19 December 2002 Outline Quick Review on Lecture 3 Topic 7: HTML Forms Topic 8: Server & CGI Scripts Class Activity
More informationA QUICK GUIDE TO PROGRAMMING FOR THE WEB. ssh (then type your UBIT password when prompted)
A QUICK GUIDE TO PROGRAMMING FOR THE WEB TO GET ACCESS TO THE SERVER: ssh Secure- Shell. A command- line program that allows you to log in to a server and access your files there as you would on your own
More information<form>. input elements. </form>
CS 183 4/8/2010 A form is an area that can contain form elements. Form elements are elements that allow the user to enter information (like text fields, text area fields, drop-down menus, radio buttons,
More informationForm Processing in PHP
Form Processing in PHP Forms Forms are special components which allow your site visitors to supply various information on the HTML page. We have previously talked about creating HTML forms. Forms typically
More informationCMPS 401 Survey of Programming Languages
CMPS 401 Survey of Programming Languages Programming Assignment #4 PHP Language On the Ubuntu Operating System Write a PHP program (P4.php) and create a HTML (P4.html) page under the Ubuntu operating system.
More informationJavaScript Functions, Objects and Array
JavaScript Functions, Objects and Array Defining a Function A definition starts with the word function. A name follows that must start with a letter or underscore, followed by any number of letters, digits,
More informationCSE 154 LECTURE 8: FORMS
CSE 154 LECTURE 8: FORMS Web data most interesting web pages revolve around data examples: Google, IMDB, Digg, Facebook, YouTube, Rotten Tomatoes can take many formats: text, HTML, XML, multimedia many
More informationMore loops. Control structures / flow control. while loops. Loops / Iteration / doing things over and over and over and over...
Control structures / flow control More loops while loops if... else Switch for loops while... do.. do... while... Much of this material is explained in PHP programming 2nd Ed. Chap 2 Control structures
More informationCPSC 481: CREATIVE INQUIRY TO WSBF
CPSC 481: CREATIVE INQUIRY TO WSBF J. Yates Monteith, Fall 2013 Schedule HTML and CSS PHP HTML Hypertext Markup Language Markup Language. Does not execute any computation. Marks up text. Decorates it.
More informationPHP: Hypertext Preprocessor. A tutorial Introduction
PHP: Hypertext Preprocessor A tutorial Introduction Introduction PHP is a server side scripting language Primarily used for generating dynamic web pages and providing rich web services PHP5 is also evolving
More informationControlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.
Controlled Assessment Task Question 1 - Describe how this HTML code produces the form displayed in the browser. The form s code is displayed in the tags; this creates the object which is the visible
More informationPrincess Nourah bint Abdulrahman University. Computer Sciences Department
Princess Nourah bint Abdulrahman University Computer Sciences Department 1 And use http://www.w3schools.com/ PHP Part 3 Objectives Creating a new MySQL Database using Create & Check connection with Database
More informationChapter 6 Part2: Manipulating MySQL Databases with PHP
IT215 Web Programming 1 Chapter 6 Part2: Manipulating MySQL Databases with PHP Jakkrit TeCho, Ph.D. Business Information Technology (BIT), Maejo University Phrae Campus Objectives In this chapter, you
More informationPHP INTERVIEW QUESTION-ANSWERS
1. What is PHP? PHP (recursive acronym for PHP: Hypertext Preprocessor) is the most widely used open source scripting language, majorly used for web-development and application development and can be embedded
More informationweb.py Tutorial Tom Kelliher, CS 317 This tutorial is the tutorial from the web.py web site, with a few revisions for our local environment.
web.py Tutorial Tom Kelliher, CS 317 1 Acknowledgment This tutorial is the tutorial from the web.py web site, with a few revisions for our local environment. 2 Starting So you know Python and want to make
More informationWeb Programming. Dr Walid M. Aly. Lecture 10 PHP. lec10. Web Programming CS433/CS614 22:32. Dr Walid M. Aly
Web Programming Lecture 10 PHP 1 Purpose of Server-Side Scripting database access Web page can serve as front-end to a database Ømake requests from browser, Øpassed on to Web server, Øcalls a program to
More informationWeb Systems Nov. 2, 2017
Web Systems Nov. 2, 2017 Topics of Discussion Using MySQL as a Calculator Command Line: Create a Database, a Table, Insert Values into Table, Query Database Using PhP API to Interact with MySQL o Check_connection.php
More informationWhat is PHP? [1] Figure 1 [1]
PHP What is PHP? [1] PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use Figure
More informationUsing htmlarea & a Database to Maintain Content on a Website
Using htmlarea & a Database to Maintain Content on a Website by Peter Lavin December 30, 2003 Overview If you wish to develop a website that others can contribute to one option is to have text files sent
More informationLast &me: Javascript (forms and func&ons)
Let s debug some code together: hkp://www.clsp.jhu.edu/~anni/cs103/test_before.html hkp://www.clsp.jhu.edu/~anni/cs103/test_arer.html
More informationCICS 515 b Internet Programming. Mike Feeley
CICS 515 b Internet Programming Mike Feeley Overview of course web resources www.cs.ubc.ca/~feeley/cics515 www.w3schools.com learn to use key web technology HTML Javascript XML PHP, Ruby and Java Server
More informationSlide 1. Chapter 5. How to use the MVC pattern to organize your code. 2010, Mike Murach & Associates, Inc. Murach's PHP and MySQL, C5
Slide 1 Chapter 5 How to use the MVC pattern to organize your code and MySQL, C5 Slide 2 Objectives Applied 1. Use the MVC pattern to develop your web applications. 2. Create and use functions that do
More informationCOSC344 Database Theory and Applications PHP & SQL. Lecture 14
COSC344 Database Theory and Applications Lecture 14: PHP & SQL COSC344 Lecture 14 1 Last Lecture Java & SQL Overview This Lecture PHP & SQL Revision of the first half of the lectures Source: Lecture notes,
More informationCIS 339 Section 2. What is JavaScript
CIS 339 Section 2 Introduction to JavaScript 9/26/2001 2001 Paul Wolfgang 1 What is JavaScript An interpreted programming language with object-oriented capabilities. Shares its syntax with Java, C++, and
More information1 Form Basics CSC309
1 Form Basics Web Data 2! Most interesting web pages revolve around data! examples: Google, IMDB, Digg, Facebook, YouTube! can take many formats: text, HTML, XML, multimedia! Many of them allow us to access
More informationCSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus
CSCI-UA:0060-02 Database Design & Web Implementation Professor Evan Sandhaus sandhaus@cs.nyu.edu evan@nytimes.com Lecture #18: PHP: The PHP Hypertext Preprocessor Database Design and Web Implementation
More informationPHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008.
PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008. Outline. How cookies work. Cookies in PHP. Sessions. Databases. Cookies. Sometimes it is useful to remember a client when it comes
More informationweek8 Tommy MacWilliam week8 October 31, 2011
tmacwilliam@cs50.net October 31, 2011 Announcements pset5: returned final project pre-proposals due Monday 11/7 http://cs50.net/projects/project.pdf CS50 seminars: http://wiki.cs50.net/seminars Today common
More informationWeb Programming Paper Solution (Chapter wise)
PHP Session tracking and explain ways of session tracking. Session Tracking HTTP is a "stateless" protocol which means each time a client retrieves a Web page, the client opens a separate connection to
More informationCSCB20 Week 8. Introduction to Database and Web Application Programming. Anna Bretscher* Winter 2017
CSCB20 Week 8 Introduction to Database and Web Application Programming Anna Bretscher* Winter 2017 *thanks to Alan Rosselet for providing the slides these are adapted from. Web Programming We have seen
More informationWeb Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel
Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel Introduction: PHP (Hypertext Preprocessor) was invented by Rasmus Lerdorf in 1994. First it was known as Personal Home Page. Later
More informationWhat is MySQL? [Document provides the fundamental operations of PHP-MySQL connectivity]
What is MySQL? [Document provides the fundamental operations of PHP-MySQL connectivity] MySQL is a database. A database defines a structure for storing information. In a database, there are tables. Just
More informationDatabase Connectivity using PHP Some Points to Remember:
Database Connectivity using PHP Some Points to Remember: 1. PHP has a boolean datatype which can have 2 values: true or false. However, in PHP, the number 0 (zero) is also considered as equivalent to False.
More informationUse of PHP for DB Connection. Middle and Information Tier. Middle and Information Tier
Use of PHP for DB Connection 1 2 Middle and Information Tier PHP: built in library functions for interfacing with the mysql database management system $id = mysqli_connect(string hostname, string username,
More informationCSc 337 Final Examination December 13, 2013
On my left is: (NetID) MY NetID On my right is: (NetID) CSc 337 Final Examination December 13, 2013 READ THIS FIRST Read this page now but do not turn this page until you are told to do so. Go ahead and
More informationSystems Programming & Scripting
Systems Programming & Scripting Lecture 19: Database Support Sys Prog & Scripting - HW Univ 1 Typical Structure of a Web Application Client Internet Web Server Application Server Database Server Third
More informationQ1. What is JavaScript?
Q1. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight programming language JavaScript is usually embedded
More informationSQL-PL Interface. Murali Mani. Perl /CGI with Oracle/mySQL Install your own web server and use servlets with JDBC and Oracle/mySQL
SQL-PL Interface Some Possible Options Web Interface Perl /CGI with Oracle/mySQL Install your own web server and use servlets with JDBC and Oracle/mySQL Non-Web Interface JDBC with Oracle/mySQL Also other
More informationJavaScript s role on the Web
Chris Panayiotou JavaScript s role on the Web JavaScript Programming Language Developed by Netscape for use in Navigator Web Browsers Purpose make web pages (documents) more dynamic and interactive Change
More informationLecture 3: Web Servers / PHP and Apache. CS 383 Web Development II Monday, January 29, 2018
Lecture 3: Web Servers / PHP and Apache CS 383 Web Development II Monday, January 29, 2018 Server Configuration One of the most common configurations of servers meant for web development is called a LAMP
More informationPHP Dynamic Web Pages, Without Knowing Beans
PHP Dynamic Web Pages, Without Knowing Beans Kimberly Bobrow Jennery Intelliclass kimberly@bobrow.net kimberly@jennery.com Page Agenda Introduction Basic Syntax General Language Constructs File Handling
More information4th year. more than 9 years. more than 6 years
4th year more than 9 years more than 6 years Apache (recommended) IIS MySQL (recommended) Oracle Client Webserver www.xyz.de Webpage (Output) Output Call MySQL-Database Dataexchange PHP Hello World
More informationITS331 IT Laboratory I: (Laboratory #11) Session Handling
School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University ITS331 Information Technology Laboratory I Laboratory #11: Session Handling Creating
More informationEnterprise Knowledge Platform Adding the Login Form to Any Web Page
Enterprise Knowledge Platform Adding the Login Form to Any Web Page EKP Adding the Login Form to Any Web Page 21JAN03 2 Table of Contents 1. Introduction...4 Overview... 4 Requirements... 4 2. A Simple
More informationChapters 10 & 11 PHP AND MYSQL
Chapters 10 & 11 PHP AND MYSQL Getting Started The database for a Web app would be created before accessing it from the web. Complete the design and create the tables independently. Use phpmyadmin, for
More informationRunning SQL in Java and PHP
Running SQL in Java and PHP FCDB 9.6 9.7 Dr. Chris Mayfield Department of Computer Science James Madison University Mar 01, 2017 Introduction to JDBC JDBC = Java Database Connectivity 1. Connect to the
More informationHyper- Any time any where go to any web pages. Text- Simple Text. Markup- What will you do
HTML Interview Questions and Answers What is HTML? Answer1: HTML, or HyperText Markup Language, is a Universal language which allows an individual using special code to create web pages to be viewed on
More informationPHP Hypertext Preprocessor
PHP Hypertext Preprocessor A brief survey Stefano Fontanelli stefano.fontanelli@sssup.it January 16, 2009 Stefano Fontanelli stefano.fontanelli@sssup.it PHP Hypertext Preprocessor January 16, 2009 1 /
More informationUse of PHP for DB Connection. Middle and Information Tier
Client: UI HTML, JavaScript, CSS, XML Use of PHP for DB Connection Middle Get all books with keyword web programming PHP Format the output, i.e., data returned from the DB SQL DB Query Access/MySQL 1 2
More informationPHP Reference. To access MySQL manually, run the following command on the machine, called Sources, where MySQL and PhP have been installed:
PHP Reference 1 Preface This tutorial is designed to teach you all the PHP commands and constructs you need to complete your PHP project assignment. It is assumed that you have never programmed in PHP
More informationJavaScript. What s wrong with JavaScript?
JavaScript 1 What s wrong with JavaScript? A very powerful language, yet Often hated Browser inconsistencies Misunderstood Developers find it painful Lagging tool support Bad name for a language! Java
More informationClient Side JavaScript and AJAX
Client Side JavaScript and AJAX Client side javascript is JavaScript that runs in the browsers of people using your site. So far all the JavaScript code we've written runs on our node.js server. This is
More informationCSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus
CSCI-UA:0060-02 Database Design & Web Implementation Professor Evan Sandhaus sandhaus@cs.nyu.edu evan@nytimes.com Lecture #28: This is the end - the only end my friends. Database Design and Web Implementation
More informationStudent, Perfect Final Exam May 25, 2006 ID: Exam No CS-081/Vickery Page 1 of 6
Student, Perfect Final Exam May 25, 2006 ID: 9999. Exam No. 3193 CS-081/Vickery Page 1 of 6 NOTE: It is my policy to give a failing grade in the course to any student who either gives or receives aid on
More informationHow to use the MVC pattern to organize your code
Chapter 5 How to use the MVC pattern to organize your code The MVC pattern 2017, Mike Murach & Associates, Inc. C5, Slide 1 2017, Mike Murach & Associates, Inc. C5, Slide 4 Objectives Applied 1. Use the
More informationHTML forms and the dynamic web
HTML forms and the dynamic web Antonio Lioy < lioy@polito.it > english version created by Marco D. Aime < m.aime@polito.it > Politecnico di Torino Dip. Automatica e Informatica timetable.html departure
More informationLab 7 Introduction to MySQL
Lab 7 Introduction to MySQL Objectives: During this lab session, you will - Learn how to access the MySQL Server - Get hand-on experience on data manipulation and some PHP-to-MySQL technique that is often
More informationCSC Javascript
CSC 4800 Javascript See book! Javascript Syntax How to embed javascript between from an external file In an event handler URL - bookmarklet
More informationFirst Simple Interactive JSP example
Let s look at our first simple interactive JSP example named hellojsp.jsp. In his Hello User example, the HTML page takes a user name from a HTML form and sends a request to a JSP page, and JSP page generates
More informationSchool of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University
School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University ITS351 Database Programming Laboratory Laboratory #9: PHP & Form Processing III Objective:
More informationMount Saint Mary College, Newburgh, NY Internet Programming III - CIT310
Warm up mini-lab Lab 1 - Functions Type in the following function definition and calls to the function. Test it and understand it. function myprint($str= No String Supplied ) // the argument is optional
More informationRunning SQL in Java and PHP
Running SQL in Java and PHP FCDB 9.6 9.7 Dr. Chris Mayfield Department of Computer Science James Madison University Feb 28, 2018 Introduction to JDBC JDBC = Java Database Connectivity 1. Connect to the
More informationc360 Web Connect Configuration Guide Microsoft Dynamics CRM 2011 compatible c360 Solutions, Inc. c360 Solutions
c360 Web Connect Configuration Guide Microsoft Dynamics CRM 2011 compatible c360 Solutions, Inc. www.c360.com c360 Solutions Contents Overview... 3 Web Connect Configuration... 4 Implementing Web Connect...
More informationThe Hypertext Markup Language (HTML) Part II. Hamid Zarrabi-Zadeh Web Programming Fall 2013
The Hypertext Markup Language (HTML) Part II Hamid Zarrabi-Zadeh Web Programming Fall 2013 2 Outline HTML Structures Tables Forms New HTML5 Elements Summary HTML Tables 4 Tables Tables are created with
More informationCS4604 Prakash Spring 2016! Project 3, HTML and PHP. By Sorour Amiri and Shamimul Hasan April 20 th, 2016
CS4604 Prakash Spring 2016! Project 3, HTML and PHP By Sorour Amiri and Shamimul Hasan April 20 th, 2016 Project 3 Outline 1. A nice web interface to your database. (HTML) 2. Connect to database, issue,
More informationExecuting Simple Queries
Script 8.3 The registration script adds a record to the database by running an INSERT query. 1
More informationCreate Basic Databases and Integrate with a Website Lesson 5
Create Basic Databases and Integrate with a Website Lesson 5 Forum Project In this lesson we will be creating a simple discussion forum which will be running from your domain. If you wish you can develop
More informationCourse Wiki. Today s Topics. Web Resources. Amazon EC2. Linux. Apache PHP. Workflow and Tools. Extensible Networking Platform 1
Today s Topics Web Resources Amazon EC2 Linux Apache PHP Workflow and Tools Extensible Networking Platform 1 1 - CSE 330 Creative Programming and Rapid Prototyping Course Wiki Extensible Networking Platform
More informationChapter 9. Managing State Information. Understanding State Information (continued) Understanding State Information 10/29/2011.
Chapter 9 Managing State Information PHP Programming with MySQL 2 nd Edition Objectives In this chapter, you will: Learn about state information Use hidden form fields to save state information Use query
More informationCreating Forms. Speaker: Ray Ryon
Creating Forms Speaker: Ray Ryon In this lesson we will discuss how to create a web form. Forms are useful because they allow for input from a user. That input can then be used to respond to the user with
More informationHTML Forms. By Jaroslav Mohapl
HTML Forms By Jaroslav Mohapl Abstract How to write an HTML form, create control buttons, a text input and a text area. How to input data from a list of items, a drop down list, and a list box. Simply
More informationPHP for PL/SQL Developers. Lewis Cunningham JP Morgan Chase
PHP for PL/SQL Developers Lewis Cunningham JP Morgan Chase 1 What is PHP? PHP is a HTML pre-processor PHP allows you to generate HTML dynamically PHP is a scripting language usable on the web, the server
More informationCERTIFICATE IN WEB PROGRAMMING
COURSE DURATION: 6 MONTHS CONTENTS : CERTIFICATE IN WEB PROGRAMMING 1. PROGRAMMING IN C and C++ Language 2. HTML/CSS and JavaScript 3. PHP and MySQL 4. Project on Development of Web Application 1. PROGRAMMING
More informationDC71 INTERNET APPLICATIONS DEC 2014
Q.2 a. What are the Core Attributes of XHTML elements? Id - Uniquely identifies the element in a page. All ids in a document must be distinct. Among other uses, a URL ending in #some id can lead directly
More information