Create Basic Databases and Integrate with a Website Lesson 3

Size: px
Start display at page:

Download "Create Basic Databases and Integrate with a Website Lesson 3"

Transcription

1 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 two interact. So the main purpose of this lesson is to learn how to: Connect to MySQL using PHP Insert and select data through PHP scripts To successfully use the PHP functions to talk to MySQL, you must have MySQL running at a location at which your web server can connect. This does not necessarily mean the same machine as your web server. You also must have created a user (with a password), and you must know the name of the database to which you want to connect. WAMPServer should have solved most of these problems for you, and I could also setup an account on your domain. When using WAMPServer on localhost, the username will be root with no password. When using your domain the database is db.username.cessnock-ict.net, with the username being your usual username and a password of student1 Connecting to MySQL The mysql_connect() function is the first function you must call when using a PHP script to connect to a MySQL database. The basic syntax for the connection is: msql_connect( hostname, username, password ); This function returns a connection index (or pointer) if the connection is successful, or returns false if it fails for any reason. So to use it properly you need to store the returning index/pointer in a variable. For example: $connection = msql_connect( hostname, username, password ); You would then be able to test the connection, which we will cover shortly, but first let s see if we can connect on our localhost, then close the connection. Closing a connection The connection normally closes when the script finishes executing. But if you explicitly want to close a connection, simply use the mysql_close() function at the end of the script. Using the example above, the syntax would be: mysql_close($connection) Your script will still run if you do not include this command but too many open MySQL connections can cause problems for a web host. It is good practice to always include this line once you have issued all your commands to the database, to keep the server running well. Test the localhost connection Create the script below to open a connection using localhost. Remember you will need Apache and MySQL running as a background process. $conn = mysql_connect("localhost", "root", ""); echo $conn; Create a folder C:\wamp\www\mydatabase and save the code above as connect.php in that folder. 1

2 Apache sees the C:\wamp\www\ directory as the root directory of your web server e.g. (or Since the www folder represents the root directory of your local web server, /mydatabase runs below that root folder. The full address of the file s location would be: If you were to use the C:\Data directory from the last lesson, Apache would not know how to load the file. Apache would need to be configured to use any other folders, since that is a distraction we ll just use the C:\wamp\www\mydatabase folder it already knows about. To access the script, open a browser and enter the URL localhost/mydatabase/connect.php When the script executes you should get a response like: Resource id #1 If the connection is unsuccessful you will get an error message, otherwise you get the message above. For the time being, just accept the output until we learn how to extract information from the connection object. Just know that all is good and right with the world if we get a Resource id #. Selecting the Database After you have connected to the MySQL host (server) you must then select (USE) the database. This must be a database that your username has access to. The function is mysql_select_db() and has the syntax mysql_select_db( database_name, connection_index ) So if we had were using our Car_Sales database and used the connection index from the example above, the command would be: mysql_select_db( Car_Sales, $conn ); Once again there is the possibility that the function will fail. To take this into account and give us some indication on where our script fails we could add the die() function. The function takes a string to be printed to the browser. The better command would Car_Sales, $conn) or die( "Unable to select Car_Sales database"); Do you notice symbol at the beginning of the line? symbol will suppress any output from the command, other than what we explicitly send as in the die( ) command. If the selection of the database fails then the output in the browser will be: Unable to select Car_Sales database This extra 'or die' part is good to use as it provides a little error control, but it is not essential. Edit the connect.php file to include selecting the Car_Sales database. Make the following changes: $conn = mysql_connect("localhost", "root", ""); echo $conn) or die( "Unable to select Car_Sales database"); Save the code and test it again. You shouldn t see any changes, unless the script fails. So now you know how to open a connection and select a database! Easy isn t it 2

3 Executing SQL Commands Now you have connected to the server and selected the database you want to work with, you can begin executing commands on the server with the mysql_query() function. The general syntax is: mysql_query( sql_query_string, connection_index); There are two ways of executing a command. One is to just enter the command in the sql_query_string. This way is used if there will be no results from the operation. The other way is to define the command as a variable. This will set the variable with the results of the operation. The second method would look like this: mysql_query($query, $conn); The useful thing about using this form of the command is that you can just repeat the same command over and over again without learning new ones. All you need to do is to change the variable. Insert an Employee Recall the Car_Sales database, created in the last lesson, has two tables - Vehicles and Employees. We are going to add another Employee to the table, but in a script. If we were entering information directly in MySQL, we would use the INSERT command like: INSERT INTO Employees (EmployeeID, Last_Name, First_Name, Position, Salary, Phone) VALUES (1006, 'Blogs', 'Joe', 'Sales Rep', 30000, ' '), Now we are going to use the SQL command above, but store it in a variable called $query, then use it. But we also would like some indication on whether the command executed properly or it failed in some way. The mysql_query() function also returns true or false reflecting the success or not of the operation. We can use that to build some feedback and error control into the script. Modify the connect.php file and make the following changes. $conn = mysql_connect("localhost", "root", $conn) or die( "Unable to select Car_Sales database"); $query = "INSERT INTO Employees(EmployeeID, Last_Name, First_Name, Position, Salary, Phone) VALUES (1006, 'Blogs', 'Joe', 'Sales Rep', 30000, ' ')"; if(mysql_query($query, $conn)){ echo "Record added successfully!"; else{ echo "Something went wrong with adding the record!"; Save the file as insert_employee.php and run it. It should provide the Record added successfully! output. Run the file again (hit refresh) and it should fail. Why? Because you can only have 1 record with a unique primary key. It s important to remember you have to take into account all the normal Relational Database issues, as well as writing the script. 3

4 Using Replaceable Variables The way we have the initial connection setup is not satisfactory. It would be more efficient and flexible (from a programming point of view) to initialise the connect parts in separate variables before we try to connect. Using this approach we can change the host, username, password in one place. Far easier to edit and make the code transportable. Make the following changes, adding variables while also adding another employee. $host = "localhost"; $username = "root"; $password = ""; $database = "Car_Sales"; $conn = mysql_connect($host, $username, $conn) or die( "Unable to select $database database"); $query = "INSERT INTO Employees(EmployeeID, Last_Name, First_Name, Position, Salary, Phone) VALUES (1007, 'Johns', 'Johno', 'Sales Rep', 30000, ' ')"; if(mysql_query($query, $conn)){ echo "Record added successfully!"; else{ echo "Something went wrong with adding the record!"; Save the file and run it. It should once again provide the Record added successfully! output. Error Messages When working on a database through a script on a web server, there are a number of possible sources of errors. But there is a useful function that can help identify the nature of MySQL related errors. The mysql_error() function will output the last error report when something goes wrong. Include this function in a location where you want to know what went wrong. Let s use the following example and modify the last echo statement: if(mysql_query($query, $conn)){ echo "Record added successfully!"; else{ Save and run the file. It should fail because there is already an entry with primary key The output generated should reflect the type of error that you would receive if you were working directly in MySQL. An error message such as: Something went wrong. MySQL reports: Duplicate entry '1007' for key 1 Adding the mysql_error() function to output messages can be a useful debugging method. Adding a Record from a Form We are going to expand our insert_employee.php script to take input from a form. So we need an HTML form with the following parts: 4

5 Action: The form s action property would be the insert_employee.php script Fields: The form should contain: First Name Last Name Position Salary Phone number Should we include the EmployeeID field in our set of available entries? Well our original definition of the Employees table stated CREATE TABLE Employees( EmployeeID INT NOT NULL PRIMARY KEY It does not have the AUTO_INCREMENT option, so YES we need to provide a key. Our first draft of the form and script will be a little rough in that regard, but we can improve on it later. Create the Add Employee Form as indicated below. <html><head> <title>add Employee</title> </head> <body> <h2>add Employee Form</h2> <form method="post" action="insert_employee.php"> <table width="450" border="0"> <td width="150">employee ID</td> <td width="300"><input type="text" name="employeeid" /> </td> <td>first Name </td> <td><input type="text" name="firstname" /></td> <td>last Name </td> <td><input type="text" name="lastname" /></td> <td>position</td> <td><input type="text" name="position" /></td> <td>salary</td> <td><input type="text" name="salary" /></td> <td>phone number </td> <td><input type="text" name="phone" /></td> <td><input type="reset" name="reset" value="cancel" /></td> <td><input type="submit" name="submit" value="add Employee Entry" /></td> </table> </form> <p> </p> </body> </html> 5

6 Save the document as add_employee.htm in the same directory as insert_employee.php. The form should look similar to the image below. Now we have a form, we need to edit the insert_employee.php file to accept the data posted to it. There are a number of changes that need to be made. For instance we need to: 1. extract all the information from the form 2. then we need to assemble a SQL query that uses those extracted values 3. execute the SQL command 4. if the addition of a new record was successful, or a failure, produce some feedback accordingly. Modify the insert_employee.php file as indicated below $host = "localhost"; $username = "root"; $password = ""; $database = "Car_Sales"; // extract the values from the form $employeeid = $_POST['EmployeeID']; $firstname = $_POST['FirstName']; $lastname = $_POST['LastName']; $position = $_POST['Position']; $salary = $_POST['Salary']; $phone = $_POST['Phone']; // assemble the sql query string to insert a record $query = "INSERT INTO Employees(EmployeeID, Last_Name, First_Name, Position, Salary, Phone) VALUES ($EmployeeID, '$lastname', '$firstname', '$position', $salary, '$phone')"; // open a connection and select the database $conn = mysql_connect($host, $username, $conn) or die( "Unable to select $database database"); // add the record if(mysql_query($query, $conn)){ echo "Record added successfully!"; else{ // reuse the previous form include("add_employee.htm"); Save the code above, and load your form in the browser. 6

7 You may have noticed that we have not included basic checking, such as the data being submitted by a post compared to a get. At this stage the focus is on the fundamental components that make it work. Enter the details as indicated by the adjacent form, and submit the form to the script. If the addition (INSERTion) of the record works as it should, you would be returned to the form. The form should indicate whether the addition was successful or not. Add another entry as indicated: After submitting the new entry adjacent, you should once again be confirmed as having added a record, and presented with the form ready to go again. Now we have couple more entries it might be time to see what is in the Employees table. Viewing Records Recall the basic SELECT statement that you use in a MySQL query to view all the records in the Employees table. SELECT * FROM Employees We will still use this basic SQL command in a script to select all the records in the Employees table, but just as before, we ll assign it to a variable first. The output from this command, when executed, will return heaps of stuff (technical term), so should be assigned to a variable that we can work with. $query = "SELECT * FROM Employees"; $result = mysql_query($query, $conn); In this case the whole contents of the database is now contained in a special array with the name $result. The $result will be in simplistic terms, a two-dimensional array. As a consequence, before you can output this data you must extract each individual record into a separate variable (which is a single array in itself). 7

8 The command to extract a single array (row of columns that amount to a single record), we use the mysql_fetch_array() function. The syntax is: $recordarray = mysql_fetch_array($result) Each time the mysql_fetch_array() function is called, it moves an internal pointer to the next record. So next time you make the same function call, you get the next record till there are none to fetch. There are other ways of extracting specific data from the returning result, but this is one of the simplest. Accessing Individual Columns As each row (record) is extracted, it is still stored as an array. There are two ways this data can be extracted, first using the subscript (index) method of normal arrays, or as an associative array using column names. Compare the two examples. $recordarray[0] $recordarray[employeeid] Counting Rows One useful piece of information to extract (apart from the actual column entries) is how many database rows were returned. To know how many rows (records) are returned, use the mysql_numrows() function. The general syntax would be: $rows = mysql_numrows($result); This will set the value of $rows to be the number of rows stored in $result (the output you got from the database). This can then be used in a loop to get all the data and output it on the screen. Let s create a script that extracts all the Employee details and displays it in an HTML table. But first we ll just test to see how many records are returned. <title>employee Details</title> </head> <body> <h2>employee Details</h2> $host = "localhost"; $username = "root"; $password = ""; $database = "Car_Sales"; // assemble the sql query string to insert a record $query = "SELECT * FROM Employees"; // open a connection and select the database $conn = mysql_connect($host, $username, $conn) or die( "Unable to select $database database"); // Execute the sql query if($result = mysql_query($query, $conn)){ $rows = mysql_numrows($result); echo "<p>there are $rows employees in the system</p>"; else{ 8

9 Save the code above as show_employees.php and run it. The result should be as show below Employee Details There are 9 employees in the system Since we have made a successful connection, and have determined there are records to display, let s edit the script to display the records. We ll need to add some more HTML to display the records neatly in a tabular format. <html><head><title>employee Details</title></head><body> <h2>employee Details</h2> $host = "localhost"; $username = "root"; $password = ""; $database = "Car_Sales"; $query = "SELECT * FROM Employees"; // assemble the sql query string to get all records // open a connection and select the database $conn = mysql_connect($host, $username, $conn) or die( "Unable to select $database database"); // Execute the sql query if($result = mysql_query($query, $conn)){ $rows = mysql_numrows($result); echo "<p>there are $rows employees in the system</p>"; <table border="1"> <td>employeed ID</td> <td>first Name</td> <td>last Name</td> <td>position</td> <td>salary</td> <td>contact Number</td> $i = 0; while($i < $rows){ $recordarray = mysql_fetch_array($result); // fetch and display a record echo " <td>$recordarray[0]</td> <td>$recordarray[2]</td> <td>$recordarray[1]</td> <td>$recordarray[3]</td> <td>$recordarray[4]</td> <td>$recordarray[5]</td> "; $i++; else{ </table> </body></html> 9

10 Save the changes above and run it. You should be output like the image below. Notice in this example the use of the index version of accessing the column (field) contents. That of $recordarray[1] Using this method is simple but harder to keep track of which column with which you are dealing. As an example, notice that the Last Name and First Name are not in the same order as the SQL statement. To make life a little easier we could modify the code to use column names instead. Make the following modifications to the code echo " <td>$recordarray[employeeid]</td> <td>$recordarray[first_name]</td> <td>$recordarray[last_name]</td> <td>$recordarray[position]</td> <td>$recordarray[salary]</td> <td>$recordarray[phone]</td> "; Save the changes and run it again. The output should be the same, just easier to follow each entry in the associative array. Getting the correct key In our current form that adds an Employee, the user is expected to know what the next ID field should be, or at least that it should even be a number. It would be more desirable if the form already contained the next available ID number. A number that is both sequentially next and valid. How could this be achieved? 10

11 If a search of the current highest entry (MAX) in the EmployeeID column was known, we could simply increment it. We would need to do this before displaying the form, and the form would need to use the incremented value in the appropriate place, so it too would need to be modified. So our plan is to: 1. Get the current highest value in the EmployeeID column of the Employees table 2. Increment the returning value, therefore giving us the next likely number 3. Display the Add Employee Form with the next number already showing Create new_employee.php The new_employee.php file will be the working engine of our new version of adding new employees. The script will perform the tasks outlined in our plan above. Since we already have the HTML form that accepts new entries, we could modify it slightly and simply include() it in our new_employee.php script. Load the add_employee.htm file in your editor and make the small change as indicated. <td width="150">employee ID</td> <td width="312"> <input type="text" name="employeeid" value="<?= $nextid " /> </td> Save the add_employee.htm file. Create a new file, called new_employee.php, that will present the form with the correct $nextid $host = "localhost"; $username = "root"; $password = ""; $database = "Car_Sales"; // assemble the sql query string $query = "SELECT MAX(EmployeeID) AS LastID FROM Employees"; // open a connection and select the database $conn = mysql_connect($host, $username, $conn) or die( "Unable to select $database database"); // get the LastID, calculate the nextid and display the form if($result = mysql_query($query, $conn)){ $row = mysql_fetch_array($result); $nextid = $row[lastid]; $nextid++; include("add_employee.htm"); else{ Save the file as new_employee.php and run it. The Add Employee Form should appear with the next available EmployeeID already entered. 11

12 There is another change as a consequence of our script. When the add_employee.htm file is included by the insert_employee.php file, there will not be any nextid to be entered once the scripts have executed. To fix the problem, edit the insert_employee.php file to call new_employee.php instead. For example, the last couple of lines of the insert_employee.php file should now be: // close the connection and execute the new_employee.php script include("new_employee.php"); Make the changes above and save the insert_employee.php file. Test out your new version by running the new_employee.php script and adding some fictitious employees of your own. Deleting Employees While we re adding some employees of our own making, it would be a worthwhile activity to be able to display all the employees and simply delete the entries we no longer require. We already have a script that displays all the employees, so we could modify that to achieve our aim. There are many ways we could go about this task. Just to show we can also use the GET method to execute some scripting goals, we will: 1. Create a delete_employee.php script that will: a. Determine the EmployeeID from a query string as part of a GET b. Delete the record for the employee c. Call the show_employees.php script 2. Modify the show_employees.php script would need to include a link that calls the delete_employee.php script, passing a query string in the URL. Create delete_employee.php file which will achieve the goals above. You will notice that most of the code is the same as the insert_employee.php, with changes to the SQL query string and how the $employeeid is obtained. The lines of code that are different are highlighted. $host = "localhost"; $username = "root"; $password = ""; $database = "Car_Sales"; // extract the value from the query string $employeeid = $_GET['EmployeeID']; // assemble the sql query string to delete a record $query = "DELETE FROM Employees WHERE EmployeeID = $employeeid"; // open a connection and select the database $conn = mysql_connect($host, $username, $conn) or die( "Unable to select $database database"); // delete the record if(mysql_query($query, $conn)){ echo "Record deleted successfully!"; else{ // close the connection and call the show_employees.php script include("show_employees.php"); Save the code above and make the following changes to the show_employees.php script. 12

13 <table border="1"> <td>employeed ID</td> <td>first Name</td> <td>last Name</td> <td>position</td> <td>salary</td> <td>contact Number</td> <td>admin Options</td> <? while($i < $rows){ // fetch a record $recordarray = mysql_fetch_array($result); echo " <td>$recordarray[employeeid]</td> <td>$recordarray[first_name]</td> <td>$recordarray[last_name]</td> <td>$recordarray[position]</td> <td>$recordarray[salary]</td> <td>$recordarray[phone]</td> <td> <a href='delete_employee.php?employeeid=$recordarray[employeeid]'>delete</a> </td> "; $i++; else{ </table> Save the changes above and run the show_employees.php script. You should be able to delete a record by clicking on the DELETE link, and it all should happen very quick! After deleting a record, take notice of the query string in the URL that s what makes it a GET and not a POST request and why we can makes things happen from a simple link. Now we have a set of scripts that can ADD and DELETE, but does not allow for EDIT employees. Editing Employees To be able to edit an employee s details we need a form that displays the details, and also submits to an update script. We could do them separately or we could do it all in a single script. In any case we can recycle the add_employee.htm file to save on typing. We will do it using 3 files simply to make each smaller. The sequence of events will be: edit_employee.php is called as a GET request from show_employees.php edit_employee.htm is displayed with details extracted from the database, the form submits to the update_employee.php script update_employee.php extracts the details from the POST and updates the database, returning to show_employees.php Copy the add_employee.htm file to one called edit_employee.htm. We are going to make the following modifications to the edit_employee.htm file. 13

14 <title>edit Employee</title> </head> <body> <h2>edit Employee Form</h2> <form method="post" action="update_employee.php"> <table width="450" border="0"> <td width="150">employee ID</td> <td width="312"><input type="hidden" name="employeeid" value="<?= $employeeid "/> <?= $employeeid </td> <td>first Name </td> <td><input type="text" name="firstname" value="<?= $firstname "/></td> <td>last Name </td> <td><input type="text" name="lastname" value="<?= $lastname " /></td> <td>position</td> <td><input type="text" name="position" value="<?= $position " /></td> <td>salary</td> <td><input type="text" name="salary" value="<?= $salary " /></td> <td>phone number </td> <td><input type="text" name="phone" value="<?= $phone " /></td> <td><input type="reset" name="reset" value="reset" /></td> <td><input type="submit" name="submit" value="update Employee Entry" /></td> </table> <input type="button" name="cancel" value="cancel and Return" onclick="javascript:window.history.go(-1);" /> </form> Save the changes to edit_employee.htm. Notice that we are using a hidden text field rather than having the EmployeeID displayed in a normal text input field. This is to prevent the user accidentally changing the EmployeeID which would make the whole process collapse. Also, we have added a Cancel and Return button to allow the whole operation to be cancelled. Now create the script that will extract the employee s details and present them in the form above. $host = "localhost"; $username = "root"; $password = ""; $database = "Car_Sales"; // extract the employeeid from the GET request $employeeid = $_GET['EmployeeID']; 14

15 // assemble the sql query string to extract a record $query = "SELECT * FROM Employees WHERE EmployeeID = $employeeid"; // open a connection and select the database $conn = mysql_connect($host, $username, $conn) or die( "Unable to select $database database"); // Execute the sql query and extract the column values if($result = mysql_query($query, $conn)){ $record = mysql_fetch_array($result); $firstname = $record['first_name']; $lastname = $record['last_name']; $position = $record['position']; $salary = $record['salary']; $phone = $record['phone']; else{ include("edit_employee.htm"); Save the code above as edit_employee.php. The next step is to create the script that actually updates the database. Create the code below that actually updates the database, then passes control back to show_employees.php. It passes control not just includes the file. $host = "localhost"; $username = "root"; $password = ""; $database = "Car_Sales"; // extract the values from the form $employeeid = $_POST['EmployeeID']; $firstname = $_POST['FirstName']; $lastname = $_POST['LastName']; $position = $_POST['Position']; $salary = $_POST['Salary']; $phone = $_POST['Phone']; // assemble the sql query string $query = "UPDATE Employees SET First_Name = '$firstname', Last_Name = '$lastname', Position = '$position', Salary = '$salary', Phone = '$phone' WHERE EmployeeId = '$employeeid'"; // open a connection and select the database $conn = mysql_connect($host, $username, $conn) or die( "Unable to select $database database"); // update the record if(mysql_query($query, $conn)){ 15

16 else{ header("location: show_employees.php"); exit; Save the code as update_employee.php. There is one small change we should make to the show_employees.php before testing it out. Load the show_employees.php and make the highlighted changes. <a href="new_employee.php">add New Employee</a><br /> <table border="1"> <td>employeed ID</td> <td>first Name</td> <td>last Name</td> <td>position</td> <td>salary</td> <td>contact Number</td> <td>admin Options</td> <? while($i < $rows){ // fetch a record $recordarray = mysql_fetch_array($result); echo " <td>$recordarray[employeeid]</td> <td>$recordarray[first_name]</td> <td>$recordarray[last_name]</td> <td>$recordarray[position]</td> <td align='right'>$recordarray[salary]</td> <td>$recordarray[phone]</td> <td><a href='delete_employee.php?employeeid=$recordarray[employeeid]'>delete</a> <a href='edit_employee.php?employeeid=$recordarray[employeeid]'>edit</a> </td> "; Save the changes above and run the show_employees.php script in the browser. The output should look the same as it did before, but with Add, Edit and Delete options. To launch the Edit process, simply click the link! Now let s see if you can use and extend the knowledge in this tutorial with a challenge or two. 16

17 Exercises Challenge 1 Create a script that shows all sold vehicles. Refer to the last tutorial if you can t recall the SQL statement. Challenge 2 Using the script in Challenge 1, add the full name of the employee that sold the vehicle Challenge 3 Create a script that displays the Make, Model, Rego_no, Cost_price and Sale_Price columns of all unsold vehicles. Challenge 4 Add a Sold link to the output, that when clicked, will launch a form to enter the Vehicle sold details for a particular Rego number. E. g. sold_vehicle.php?rego_no=$rego Challenge 5 Create a script (sold_vehicle.php) with a form that can be used to enter sold vehicles. The form should display the Make, Model, Rego_no and Sale_Price - the Sale_Price should be editable. The script should use the Rego_no passed as a GET query string i.e. from the link in Challenge 4. Challenge 6 Modify the form in Challenge 5 to include a dropdown list (HTML select) that contains all the Employee s names, with their EmployeeID as the value. For example, for each employee you would add an option to the select like this: <select name= Employee > ** loop code** <option value= <?= $employeeid > <? echo $firstname $lastname ; </option> ** end loop code** </select> To achieve this, it means there will be two separate SQL statements executed. First you could find all the employees, and save that information in an array. Then find the Vehicle information. Challenge 7 Create a script that will UPDATE the Vehicles table to indicate a vehicle has been sold. This will be the script that the form, created in Challenge 5, is submitted to. To achieve make this possible it means the EmployeeID field should contain a valid EmployeeID, an updated Sale_Price, and use the Rego_No in the WHERE clause of the SQL query. Challenge 8 Modify the scripts in this lesson to make then more manageable. This means cut the references to the host, database, usernames, connecting etc. into a separate file called db_connect.php and include this file at the top of each script that used the database. 17

By 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: 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 information

PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008.

PHP: 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 information

What is MySQL? [Document provides the fundamental operations of PHP-MySQL connectivity]

What 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 information

Database Connectivity using PHP Some Points to Remember:

Database 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 information

COM1004 Web and Internet Technology

COM1004 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 information

More loops. Control structures / flow control. while loops. Loops / Iteration / doing things over and over and over and over...

More 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 information

Chapter 6 Part2: Manipulating MySQL Databases with PHP

Chapter 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 information

Adding A PHP+MySQL Hit Counter to your Website

Adding A PHP+MySQL Hit Counter to your Website Adding A PHP+MySQL Hit Counter to your Website Setting up MySQL First off, decide what you want to keep track of. In this case, let s commit to tracking total number of hits on each of a number of web

More information

PHP Development - Introduction

PHP Development - Introduction PHP Development - Introduction Php Hypertext Processor PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports many

More information

Create Basic Databases and Integrate with a Website Lesson 5

Create 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 information

Server side scripting and databases

Server side scripting and databases Example table Server side scripting and databases student How Web Applications interact with server side databases - part 2 student kuid lastname money char char int student table Connecting and using

More information

PHP. How Web Applications interact with server side databases CRUD. Connecting and using mysql from PHP PHP provides many mysql specific functions

PHP. How Web Applications interact with server side databases CRUD. Connecting and using mysql from PHP PHP provides many mysql specific functions PHP How Web Applications interact with server side databases CRUD Connecting and using mysql from PHP PHP provides many mysql specific functions mysql_connect mysql_select_db mysql_query mysql_fetch_array

More information

Form Processing in PHP

Form 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 information

Web Programming. Dr Walid M. Aly. Lecture 10 PHP. lec10. Web Programming CS433/CS614 22:32. Dr Walid M. Aly

Web 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 information

Executing Simple Queries

Executing Simple Queries Script 8.3 The registration script adds a record to the database by running an INSERT query. 1

More information

CHAPTER 10. Connecting to Databases within PHP

CHAPTER 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 information

Databases and SQL. Lecture outline. CSE 190 M (Web Programming) Spring 2008 University of Washington

Databases and SQL. Lecture outline. CSE 190 M (Web Programming) Spring 2008 University of Washington Databases and SQL CSE 190 M (Web Programming) Spring 2008 University of Washington References: SQL syntax reference, w3schools tutorial Except where otherwise noted, the contents of this presentation are

More information

PHP Tutorial 6(a) Using PHP with MySQL

PHP 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 information

UNIT V ESTABLISHING A DATABASE CONNECTION AND WORKING WITH DATABASE

UNIT V ESTABLISHING A DATABASE CONNECTION AND WORKING WITH DATABASE UNIT V 1 ESTABLISHING A DATABASE CONNECTION AND WORKING WITH DATABASE SYLLABUS 5.1 Overview of Database 5.2 Introduction to MYSQL 5.3 Creating Database using phpmyadmin & Console(using query, using Wamp

More information

LAMP Apps. Overview. Learning Outcomes: At the completion of the lab you should be able to:

LAMP 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 information

Create Basic Databases and Integrate with a Website Lesson 2

Create Basic Databases and Integrate with a Website Lesson 2 Create Basic Databases and Integrate with a Website Lesson 2 An easy way to rebuild a system So far, in using MySQL, you would have noticed that issuing commands is problematic. You may find yourself having

More information

Chapter. Accessing MySQL Databases Using PHP

Chapter. Accessing MySQL Databases Using PHP Chapter 12 Accessing MySQL Databases Using PHP 150 Essential PHP fast Introduction In the previous chapter we considered how to create databases using MySQL. While this is useful, it does not enable us

More information

PHP Introduction. Some info on MySQL which we will cover in the next workshop...

PHP 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 information

Lecture 7: Web hacking 3, SQL injection, Xpath injection, Server side template injection, File inclusion

Lecture 7: Web hacking 3, SQL injection, Xpath injection, Server side template injection, File inclusion IN5290 Ethical Hacking Lecture 7: Web hacking 3, SQL injection, Xpath injection, Server side template injection, File inclusion Universitetet i Oslo Laszlo Erdödi Lecture Overview What is SQL injection

More information

Understanding Basic SQL Injection

Understanding Basic SQL Injection Understanding Basic SQL Injection SQL injection (also known as SQLI) is a code injection technique that occurs if the user-defined input data is not correctly filtered or sanitized of the string literal

More information

Jackson State University Department of Computer Science CSC / Advanced Information Security Spring 2013 Lab Project # 3

Jackson State University Department of Computer Science CSC / Advanced Information Security Spring 2013 Lab Project # 3 Jackson State University Department of Computer Science CSC 439-01/539-02 Advanced Information Security Spring 2013 Lab Project # 3 Use of CAPTCHA (Image Identification Strategy) to Prevent XSRF Attacks

More information

IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population

IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population In this lab, your objective is to learn the basics of creating and managing a DB system. One way to interact with the DBMS (MySQL)

More information

A QUICK GUIDE TO PROGRAMMING FOR THE WEB. ssh (then type your UBIT password when prompted)

A 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

Using PHP with MYSQL

Using PHP with MYSQL Using PHP with MYSQL PHP & MYSQL So far you've learned the theory behind relational databases and worked directly with MySQL through the mysql command-line tool. Now it's time to get your PHP scripts talking

More information

Chapters 10 & 11 PHP AND MYSQL

Chapters 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 information

ITS331 IT Laboratory I: (Laboratory #11) Session Handling

ITS331 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 information

Installing Dolphin on Your PC

Installing Dolphin on Your PC Installing Dolphin on Your PC Note: When installing Dolphin as a test platform on the PC there are a few things you can overlook. Thus, this installation guide won t help you with installing Dolphin on

More information

MYSQL DATABASE ACCESS WITH PHP

MYSQL DATABASE ACCESS WITH PHP MYSQL DATABASE ACCESS WITH PHP Fall 2010 CSCI 2910 Server-Side Web Programming Typical web application interaction Database Server 3 tiered architecture Security in this interaction is critical Web Server

More information

You can use Dreamweaver to build master and detail Web pages, which

You can use Dreamweaver to build master and detail Web pages, which Chapter 1: Building Master and Detail Pages In This Chapter Developing master and detail pages at the same time Building your master and detail pages separately Putting together master and detail pages

More information

CICS 515 b Internet Programming Week 2. Mike Feeley

CICS 515 b Internet Programming Week 2. Mike Feeley CICS 515 b Internet Programming Week 2 Mike Feeley 1 Software infrastructure stuff MySQL and PHP store files in public_html run on remote.mss.icics.ubc.ca access as http://ws.mss.icics.ubc.ca/~username/...

More information

c360 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.   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 information

Lab 7 Introduction to MySQL

Lab 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 information

the Data Drive IN THIS CHAPTER Good Things Come in Free Packages

the 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 information

PHP: Databases and Classes. CS174. Chris Pollett. Sep 29, 2008.

PHP: Databases and Classes. CS174. Chris Pollett. Sep 29, 2008. PHP: Databases and Classes. CS174. Chris Pollett. Sep 29, 2008. Outline. Databases. Classes. Connecting to MySQL from PHP. To start a connect to a MySQL database one can issue the command: $db = mysql_connect();

More information

MySQL On Crux Part II The GUI Client

MySQL On Crux Part II The GUI Client DATABASE MANAGEMENT USING SQL (CIS 331) MYSL ON CRUX (Part 2) MySQL On Crux Part II The GUI Client MySQL is the Structured Query Language processor that we will be using for this class. MySQL has been

More information

Book IX. Developing Applications Rapidly

Book IX. Developing Applications Rapidly Book IX Developing Applications Rapidly Contents at a Glance Chapter 1: Building Master and Detail Pages Chapter 2: Creating Search and Results Pages Chapter 3: Building Record Insert Pages Chapter 4:

More information

COMP519: Web Programming Autumn 2015

COMP519: Web Programming Autumn 2015 COMP519: Web Programming Autumn 2015 In the next lectures you will learn What is SQL How to access mysql database How to create a basic mysql database How to use some basic queries How to use PHP and mysql

More information

Mount Saint Mary College, Newburgh, NY Internet Programming III - CIT310

Mount 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 information

Use of PHP for DB Connection. Middle and Information Tier. Middle and Information Tier

Use 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 information

Writing Perl Programs using Control Structures Worked Examples

Writing Perl Programs using Control Structures Worked Examples Writing Perl Programs using Control Structures Worked Examples Louise Dennis October 27, 2004 These notes describe my attempts to do some Perl programming exercises using control structures and HTML Forms.

More information

Controlled 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. 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 information

Web Application Development (WAD) V th Sem BBAITM (Unit 4) By: Binit Patel

Web Application Development (WAD) V th Sem BBAITM (Unit 4) By: Binit Patel Web Application Development (WAD) V th Sem BBAITM (Unit 4) By: Binit Patel Working with Forms: A very popular way to make a web site interactive is using HTML based forms by the site. Using HTML forms,

More information

CSC 3300 Homework 3 Security & Languages

CSC 3300 Homework 3 Security & Languages CSC 3300 Homework 3 Security & Languages Description Homework 3 has two parts. Part 1 is an exercise in database security. In particular, Part 1 has practice problems in which your will add constraints

More information

2018 Computing Science. Advanced Higher. Finalised Marking Instructions

2018 Computing Science. Advanced Higher. Finalised Marking Instructions National Qualifications 2018 2018 Computing Science Advanced Higher Finalised Marking Instructions Scottish Qualifications Authority 2018 The information in this publication may be reproduced to support

More information

Lecture 13: MySQL and PHP. Monday, March 26, 2018

Lecture 13: MySQL and PHP. Monday, March 26, 2018 Lecture 13: MySQL and PHP Monday, March 26, 2018 MySQL The Old Way In older versions of PHP, we typically used functions that started with mysql_ that did not belong to a class For example: o o o o mysql_connect()

More information

Managing Your Database Using Oracle SQL Developer

Managing Your Database Using Oracle SQL Developer Page 1 of 54 Managing Your Database Using Oracle SQL Developer Purpose This tutorial introduces Oracle SQL Developer and shows you how to manage your database objects. Time to Complete Approximately 50

More information

Publish Joomla! Article

Publish Joomla! Article Enterprise Architect User Guide Series Publish Joomla! Article Sparx Systems Enterprise Architect supports publishing an entire model, or part of the model, in a local Joomla! Repository as Articles (HTML

More information

Publish Joomla! Article

Publish Joomla! Article Enterprise Architect User Guide Series Publish Joomla! Article Author: Sparx Systems Date: 10/05/2018 Version: 1.0 CREATED WITH Table of Contents Publish Joomla! Article 3 Install Joomla! Locally 4 Set

More information

School 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 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 information

Princess Nourah bint Abdulrahman University. Computer Sciences Department

Princess 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 information

Retrieving Query Results

Retrieving Query Results Using PHP with MySQL Retrieving Query Results The preceding section of this chapter demonstrates how to execute simple queries on a MySQL database. A simple query, as I m calling it, could be defined as

More information

SQL stands for Structured Query Language. SQL lets you access and manipulate databases

SQL stands for Structured Query Language. SQL lets you access and manipulate databases CMPSC 117: WEB DEVELOPMENT SQL stands for Structured Query Language SQL lets you access and manipulate databases SQL is an ANSI (American National Standards Institute) standard 1 SQL can execute queries

More information

Introduction. Why Would I Want A Database?

Introduction. Why Would I Want A Database? Introduction For many people, the main reason for learning a scripting language like PHP is because of the interaction with databases it can offer. In this tutorial I will show you how to use PHP and the

More information

주소록만들기 주소록. Input 페이지 Edit 페이지 Del 페이지

주소록만들기 주소록. Input 페이지 Edit 페이지 Del 페이지 주소록프로젝트 주소록만들기 주소록 List 페이지 Input 페이지 Edit 페이지 Del 페이지 Inputpro 페이지 Editpro 페이지 Address_Input.html 주소입력페이지 td,li,input{font-size:9pt} 주소입력

More information

Networks and Web for Health Informatics (HINF 6220) Tutorial 13 : PHP 29 Oct 2015

Networks and Web for Health Informatics (HINF 6220) Tutorial 13 : PHP 29 Oct 2015 Networks and Web for Health Informatics (HINF 6220) Tutorial 13 : PHP 29 Oct 2015 PHP Arrays o Arrays are single variables that store multiple values at the same time! o Consider having a list of values

More information

PHP for PL/SQL Developers. Lewis Cunningham JP Morgan Chase

PHP 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 information

End o' semester clean up. A little bit of everything

End o' semester clean up. A little bit of everything End o' semester clean up A little bit of everything Database Optimization Two approaches... what do you think they are? Improve the Hardware Has been a great solution in recent decades, thanks Moore! Throwing

More information

Use of PHP for DB Connection. Middle and Information Tier

Use 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 information

PHP: File upload. Unit 27 Web Server Scripting L3 Extended Diploma

PHP: File upload. Unit 27 Web Server Scripting L3 Extended Diploma PHP: File upload Unit 27 Web Server Scripting L3 Extended Diploma 2016 Criteria M2 M2 Edit the contents of a text file on a web server using web server scripting Tasks We will go through a worked example

More information

Limit Rows Selected. Copyright 2008, Oracle. All rights reserved.

Limit Rows Selected. Copyright 2008, Oracle. All rights reserved. What Will I Learn? In this lesson, you will learn to: Apply SQL syntax to restrict the rows returned from a query Demonstrate application of the WHERE clause syntax Explain why it is important, from a

More information

Including Dynamic Images in Your Report

Including Dynamic Images in Your Report Including Dynamic Images in Your Report Purpose This tutorial shows you how to include dynamic images in your report. Time to Complete Approximately 15 minutes Topics This tutorial covers the following

More information

CPET 499/ITC 250 Web Systems

CPET 499/ITC 250 Web Systems CPET 499/ITC 250 Web Systems Chapter 11 Working with Databases Part 2 of 3 Text Book: * Fundamentals of Web Development, 2015, by Randy Connolly and Ricardo Hoar, published by Pearson Paul I-Hai, Professor

More information

Using htmlarea & a Database to Maintain Content on a Website

Using 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 information

Things to note: Each week Xampp will need to be installed. Xampp is Windows software, similar software is available for Mac, called Mamp.

Things to note: Each week Xampp will need to be installed. Xampp is Windows software, similar software is available for Mac, called Mamp. Tutorial 8 Editor Brackets Goals Introduction to PHP and MySql. - Set up and configuration of Xampp - Learning Data flow Things to note: Each week Xampp will need to be installed. Xampp is Windows software,

More information

CS4604 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 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 information

Website Pros Database Component. v

Website Pros Database Component. v Website Pros Database Component v1.00.02 Table Of Contents Before Getting Started... 2 Using the Database Component... 5 How the Database Component Works... 5 Adding the Toolbar... 6 Adding Component

More information

Web Systems Nov. 2, 2017

Web 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 information

Lecture 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 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 information

CMPS 401 Survey of Programming Languages

CMPS 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 information

Apache, Php, MySql Configuration

Apache, Php, MySql Configuration 1.0 Introduction Apache, Php, MySql Configuration You will be guided to install the Apache web server and PHP and then configure them with MySQL database. There are several pre-requisite tasks MUST be

More information

IS 2150 / TEL 2810 Introduction to Security

IS 2150 / TEL 2810 Introduction to Security IS 2150 / TEL 2810 Introduction to Security James Joshi Professor, SIS Lecture 15 April 20, 2016 SQL Injection Cross-Site Scripting 1 Goals Overview SQL Injection Attacks Cross-Site Scripting Attacks Some

More information

A Primer in Web Application Development

A Primer in Web Application Development A Primer in Web Application Development The purpose of this primer is to provide you with some concept of how web applications work. You will look at some database information, some application development

More information

Simple sets of data can be expressed in a simple table, much like a

Simple sets of data can be expressed in a simple table, much like a Chapter 1: Building Master and Detail Pages In This Chapter Developing master and detail pages at the same time Building your master and detail pages separately Putting together master and detail pages

More information

Web Database Programming

Web Database Programming Web Database Programming Web Database Programming 2011 Created: 2011-01-21 Last update: 2014-01-14 Contents Introduction... 2 Use EasyDataSet as Data Source... 2 Add EasyDataSet to web page... 3 Make Database

More information

SCRIPTING, DATABASES, SYSTEM ARCHITECTURE

SCRIPTING, DATABASES, SYSTEM ARCHITECTURE introduction to SCRIPTING, DATABASES, SYSTEM ARCHITECTURE WEB SERVICES III (advanced + quiz + A11) Claus Brabrand ((( brabrand@itu.dk ))) Associate Professor, Ph.D. ((( Software and Systems ))) IT University

More information

Lab 4: Basic PHP Tutorial, Part 2

Lab 4: Basic PHP Tutorial, Part 2 Lab 4: Basic PHP Tutorial, Part 2 This lab activity provides a continued overview of the basic building blocks of the PHP server-side scripting language. Once again, your task is to thoroughly study the

More information

P - 13 Bab 10 : PHP MySQL Lanjut (Studi Kasus)

P - 13 Bab 10 : PHP MySQL Lanjut (Studi Kasus) P - 13 Bab 10 : PHP MySQL Lanjut (Studi Kasus) 10.1 Tujuan Mahasiswa mampu : Mengetahui dan Memahami Integrasi PHP dengan MySQL Mengetahui dan Memahami Relasi Dengan phpmyadmin Designer Mengetahui dan

More information

If you do not specify any custom parameters, we will deliver the message using the default names.

If you do not specify any custom parameters, we will deliver the message using the default names. Inbound SMS to UK landline numbers API HTTP GET/POST variables If you choose to have the messages delivered by HTTP, you may either use our standard parameters, or create a custom format for compatibility

More information

If Only. More SQL and PHP

If Only. More SQL and PHP If Only More SQL and PHP PHP: The if construct If only I could conditionally select PHP statements to execute. That way, I could have certain actions happen only under certain circumstances The if statement

More information

home.php 1/1 lectures/6/src/ include.php 1/1 lectures/6/src/

home.php 1/1 lectures/6/src/ include.php 1/1 lectures/6/src/ home.php 1/1 3: * home.php 5: * A simple home page for these login demos. 6: * David J. Malan 8: * Computer Science E-75 9: * Harvard Extension School 10: */ 11: // enable sessions 13: session_start();

More information

Database Systems. phpmyadmin Tutorial

Database Systems. phpmyadmin Tutorial phpmyadmin Tutorial Please begin by logging into your Student Webspace. You will access the Student Webspace by logging into the Campus Common site. Go to the bottom of the page and click on the Go button

More information

Spring 2014 Interim. HTML forms

Spring 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 information

HOW TO FLASK. And a very short intro to web development and databases

HOW TO FLASK. And a very short intro to web development and databases HOW TO FLASK And a very short intro to web development and databases FLASK Flask is a web application framework written in Python. Created by an international Python community called Pocco. Based on 2

More information

Unit 27 Web Server Scripting Extended Diploma in ICT

Unit 27 Web Server Scripting Extended Diploma in ICT Unit 27 Web Server Scripting Extended Diploma in ICT Dynamic Web pages Having created a few web pages with dynamic content (Browser information) we now need to create dynamic pages with information from

More information

Build a Subfile with PHP

Build a Subfile with PHP Build a Subfile with PHP Workshop: Build a Subfile with PHP Module 2: Formatting Customer Records in an HTML Table, and Adding a Search Form Contents Formatting Customer Records in an HTML Table, and Adding

More information

The connection has timed out

The connection has timed out 1 of 7 2/17/2018, 7:46 AM Mukesh Chapagain Blog PHP Magento jquery SQL Wordpress Joomla Programming & Tutorial HOME ABOUT CONTACT ADVERTISE ARCHIVES CATEGORIES MAGENTO Home» PHP PHP: CRUD (Add, Edit, Delete,

More information

Moodle Morsels from Sandy & Inkie. b. Click (Log in) on the upper right c. You will use your stpsb login, which is how you login to a computer

Moodle Morsels from Sandy & Inkie. b. Click (Log in) on the upper right c. You will use your stpsb login, which is how you login to a computer 1. To login to Moodle: a. https://moodle.stpsb.org Moodle Morsels from Sandy & Inkie b. Click (Log in) on the upper right c. You will use your stpsb login, which is how you login to a computer 2. Moodle

More information

web.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 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 information

PHP Arrays. Lecture 18. Robb T. Koether. Hampden-Sydney College. Mon, Mar 4, 2013

PHP Arrays. Lecture 18. Robb T. Koether. Hampden-Sydney College. Mon, Mar 4, 2013 PHP Arrays Lecture 18 Robb T. Koether Hampden-Sydney College Mon, Mar 4, 2013 Robb T. Koether (Hampden-Sydney College) PHP Arrays Mon, Mar 4, 2013 1 / 29 1 PHP Arrays 2 Iteration Structures 3 Displaying

More information

Database Programming - Section 18. Instructor Guide

Database Programming - Section 18. Instructor Guide Database Programming - Section 18 Instructor Guide Table of Contents...1 Lesson 1 - Certification Exam Preparation...1 What Will I Learn?...2 Why Learn It?...3 Tell Me / Show Me...4 Try It / Solve It...5

More information

CSc 337 Final Examination December 13, 2013

CSc 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 information

PHP. M hiwa ahamad aziz Raparin univercity. 1 Web Design: Lecturer ( m hiwa ahmad aziz)

PHP. M hiwa ahamad aziz  Raparin univercity. 1 Web Design: Lecturer ( m hiwa ahmad aziz) PHP M hiwa ahamad aziz www.raparinweb.com Raparin univercity 1 Server-Side Programming language asp, asp.net, php, jsp, perl, cgi... 2 Of 68 Client-Side Scripting versus Server-Side Scripting Client-side

More information

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Review Content Management (cont.) Replace all txt files with database tables Expand PHP/MySQL SELECT, UPDATE & DELETE queries Permit full editorial control over content

More information

Advanced Authoring Templates for WebSphere Portal content publishing

Advanced Authoring Templates for WebSphere Portal content publishing By David Wendt (wendt@us.ibm.com) Software Engineer, IBM Corp. October 2003 Advanced Authoring Templates for WebSphere Portal content publishing Abstract This paper describes some advanced techniques for

More information

The Seven Steps To Better PHP Code

The Seven Steps To Better PHP Code Welcome The Seven Steps To Better PHP Code (Part Two) Who I Am PHP enthusiast since 2000 IT and PHP Consultant From Munich, Germany University Degree in Computer Science Writer (Books and Articles) Blog:

More information