You are on page 1of 2

Medical Informatics (BIOM9450)

Tutorial 7: Student registration with PHP, cookie and include.

Objective:
The main goal of this assignment is to acquaint students with PHP sessions, cookies, and the include
functionality. Through creating a modular user preference system, students will learn to better structure their
PHP applications.

Scenario:
You're tasked with developing a user-friendly website for a local library. To provide a personalized experience,
users should have the ability to adjust certain visual elements of the site. The website should remember these
settings on subsequent visits.

Tasks
1. Setting Up PHP on Your Machine
To ensure that PHP runs smoothly on your machine and integrates properly with Visual Studio, you need to
do the following:

1.1. Download the PHP Binaries for Windows/Mac:


Navigate to the official PHP for download page: https://windows.php.net/download/.
Under the VC15 x64 Non Thread Safe or similar section (depending on your system), download the Zip
package.

1.2. Extract the PHP Files:


Once the download is complete, locate the .zip file and extract it.
For organization and easier access, extract the files to a directory like C:\php.

1.3. Update the php.ini Configuration:


In the extracted PHP directory, you'll find a file named php.ini-development. Rename this file to php.ini.
Open php.ini in a text editor with administrative rights (this is important because you'll need permissions to
save changes).
Customize settings as needed. For beginners, the default settings are usually sufficient.
1.4. Add PHP to Windows PATH:
Right-click on This PC or Computer and select Properties.
Click on Advanced system settings on the left.
In the System Properties window, click on the Environment Variables button.
Under the System Variables section, find and select the Path variable and click Edit.
In the Edit Environment Variable window, click the New button and paste the path to the PHP directory (e.g.,
C:\php).
Confirm all dialogs with OK to save the changes.

1.5. php.ini setting up


extension=pdo_mysql
;extension=pdo_oci
extension=pdo_odbc
;extension=pdo_pgsql
;extension=pdo_sqlite
;extension=pgsql
;extension=shmop

1.6. Verify PHP Installation:


Verifying the PHP installation ensures that PHP was correctly added to the system's PATH and can be
accessed from any command prompt or terminal window. It also ensures that PHP is functioning as
expected.
1.5.1 Open Command Prompt:
Press Windows + R to open the 'Run' dialog.
Type cmd and press Enter (or click OK). This will open the Command Prompt.
1.5.2. Check PHP Version:
In the Command Prompt, type the following command:
Copy code
php -v

1|Page
Press Enter.
If PHP was installed and configured correctly, you should see an output similar to the following (though the
exact version number and details might differ):
PHP 7.4.10 (cli) (built: Sep 1 2020 16:52:32) (ZTS Visual C++ 2017 x64)

2. Adding PHP Tools to Microsoft Visual Studio


2.1. Launch Microsoft Visual Studio:
Start Visual Studio. If you don’t already have it installed, you can get it from the official Microsoft website.

2.2. Open the Extensions Manager:


Click on the "Extensions" menu at the top.
From the dropdown, select "Manage Extensions."

2.3. Search for the PHP Tools:


In the "Manage Extensions" window, there's a search box in the top-right corner. Type "PHP" into this box.
Look for "PHP Tools for Visual Studio" in the search results. This is one of the most popular and
comprehensive PHP extensions for Visual Studio.

2.4. Install PHP Tools:


Click on "PHP Tools for Visual Studio" from the search results to select it.
An "Install" or "Download" button should appear on the right side. Click on it.
Visual Studio might prompt you to close it during the installation. Ensure you've saved any work, then
proceed to close Visual Studio if asked.

2.5. Restart Visual Studio:


After the installation completes, you will likely be prompted to restart Visual Studio. Do so.
If you weren’t prompted, it’s still a good idea to restart Visual Studio manually to ensure the PHP tools are
fully integrated.

2.6. Verify the Installation:


Once you've restarted Visual Studio, you can verify the installation by trying to create a new PHP project.
Go to "File" > "New" > "Project…" and then look for PHP in the list of project types. If you see PHP options,
the extension has been successfully installed.

3. Practical examples
Now practice examples 24-26 of the lecture.
Refine the include file by adding more menu from online resources.

Good luck! 😊

BIOM9450 Team

2|Page

You might also like