Tag Archives: php

Database Management System for Online Ticket Sales

Database Management System (DBMS) of online ticket sale for the stage play “Kusa-Paba” at the University of Calgary Theater.

Abstract and Project Description

The University of Calgary Theater has 500 available seats. This particular DBMS is built to allow users to order and purchase tickets online. Tickets sold by agents can also be entered to the system using the agents’ interface. Only a designated set of seats are available for sale. Some are as for reserved guests and others are designated as House Seats hence they are not available for sale. The designated seats for sale are categorized for different price levels; $50.00, $30.00 and $20.00 (Figure 1). The price levels are further broken down for adults and children.

Continue reading Database Management System for Online Ticket Sales

Maximum Input Variables WP Error

The max_input_vars limitation error is a very common issue that most WordPress web developers and website owners may encounter at some point in their career. Few days ago, my website also experienced the same problem. The solution is very simple; increase the value assigned to max_input_vars in the PHP configuration file on the web server. However, depending on server setup, you may have to do few more things to get this problem fixed.

Warning
Editing php.ini may result in complete failure of the php module and it may put your website out of service. If you are hesitant about something, hire a professional. I take no responsibility for any issues arise out of the following instructions.

Continue reading Maximum Input Variables WP Error

Protect and secure WordPress admin

The plain HTML based websites are no longer popular on the net. This is because the PHP based Content Management Systems (CMS) offer wide range of flexible solutions. From development stand point CMS programs allow easy integration of different tools such as jQuery, JavaScipt, PHP scripts and many more. From end-user point of view, it is much easier to manage a CMS based site like a WordPress or a Drupal site than to carefully edit each HTML Continue reading Protect and secure WordPress admin

Installing web applications

There are two major platforms used commercially for web development; Microsoft Windows Server and Linux based OS versions such as Red Hat Enterprise. You could also get a fully operational free version of Linux Operating Systems for personal or small business use. Out of the two main platforms, the most popular one among large companies is Microsoft Windows Server. I will demonstrate how to install a Web Application using the Microsoft Web Platform Installer (version 4.6 to be exact).

Web Applications

Web Applications, Scripts or web modules are programs that can be installed on a server to manage web based media. It can be databases such as SQL, or server side languages such as PHP, or web Content Management Systems (CMS) such as WordPress and Drupal. Some of these programs depend on others. Drupal and WordPress depend on PHP database so a server must have the PHP module installed to support them.

Microsoft Web Platform Installer (Web PI)

Web PI is a free software package (yep… it is legally free) developed and distributed by Microsoft. You can download it here. In includes a large repository of free web applications for web development and deployment. To install it, you need a Windows based operating system. It could be a server type OS or a regular desktop OS like Windows XP, 7, 8, etc. Check their website for supported systems.

I will use the Web PI 4.6 installed on Windows Server 2012 Datacenter OS for my examples. But the process is the same/similar regardless of the Operating System. Please note that this article explains the Server Administer side installation process. The client side installation process, which you usually get through a web hosting company, has a completely different installation process (on shared hosting).

Installing WordPress Web App

WordPress is the most popular platform for blogging for awhile. Recently full-blown websites have been built on it. The WordPress platform became popular because it has an easy to use user interface and a streamline update system. Naturally, I will use the WordPress Web Application as an example. But you can install any other program or application using Web PI following the same steps.

1) After installing Web PI, select “Products” tab from the top. Install “ISS XX.XX Express” and “ISS Recommended Configuration”. You may have already installed these on your server during the initial setup of the system.

MS Web PI Products Tab. Make sure the key components are installed.
MS Web PI Products Tab. Make sure the key components are installed-Click to enlarge.

If the PHP module is not installed, you will be prompt to install during the install of applications that depends on it. Since we are going to install WordPress, you may also install the PHP module now.

2) Select “Applications” tab and “Add” all the Web Apps you would like to install. You may install more than one at a time. After adding, press “Install”.

MS Web PI Applications Tab. Add for installation.
MS Web PI Applications Tab. Add for installation-Click to enlarge.

In this particular example, I will be installing one application; WordPress for Windows. Other options include variety of CMS such as Drupal, Joomla, Orchard, .NET, etc and web programs such as Moodle, Gallery Server Pro, etc.

3) The PREREQUISITES Window will check for all dependencies. If a dependency such as SQL or PHP is not installed, this will add those to the installation process. Accept for installation. Depend on the speed of your computer components, it will be installed in few seconds to a few minus period.

Prerequisites for WordPress Web Application.
Prerequisites for WordPress Web Application-Click to enlarge.

Application installation process.
Application installation process-Click to enlarge.

4) Once installation is completed, you will be greeted with the CONFIGURE Window. Select the location of install in your system from “Web Site” drop-down. The “application name” will determine the folder in which the installation will be done. In this case I choose “wp” as my application name. Hence the final access will be at http://localhost:80/wp and you may change the root folder of the site later. Keep reading this article for more information on how to do that.

WordPress installation server location setup.
WordPress installation server location setup-Click to enlarge.

5) The next CONFIGURE Window has a form which user should edit. Do not panic! All those “Keys” can be confusing. Just enter either a random set of numbers and letter or something meaningful to you. It does not matter what you enter. I usually use the exact same set of characters for all of the options. Press “Continue”.

Web Application Configuration Window. Type several characters for each option (key).
Web Application Configuration Window. Type several characters for each option (key)-Click to enlarge.

6) Record all the “Password Settings” information under the FINISH Window. You may “Copy to clipboard” and paste it somewhere for saving as well. I usually save in a Text file.

Password Settings for WordPress app Install.
Password Settings for WordPress app Install-Click to enlarge.

Now you may visit the site by selecting “Launch WordPress” or you may simply type the location address in Step 4 on a Internet window. Close the windows by pressing “Finish”. The first thing you will see on the Internet window is a setup page. Each Web App has its’ own setup page. In this particular example, it will be a WordPress CMS setup page. This is the final step!

WordPress CMS setup page.
WordPress CMS setup page-Click to enlarge.

Additional options

We setup the Web App in a folder named “wp” in Step 4. But let’s say your client insists that their website should not have “wp” as prefix (http://example.com/wp). You do not have to reinstall everything. You do not have to relocate the folders on the server either. What you need to do is to go to the domain settings and make “wp” your root folder. Now the http://example.com/wp will be http://example.com/. Another way to do this is through domain registrar options. You can point the domain name to wp folder from there as a root.

As mention before, you may install any of the Web Applications on a single server. They very lightweight programs, that they will not effect the performance of the server (but the traffic flow will). I highly recommend using different folders for each Web Application. This will avoid conflicts between them.

By default, all web applications take Port 80 (HTTP port) over others. However, you may also change this to whatever the port you want. You may ask, why would you want to use non-standard port? One reason would be that you are a developer or a student. If your ISP blocked access to Port 80, then you can bypass this by using a different port and utilizing port forwarding.

Random Item from CMS Database

There are few ways to do this in WordPress CMS using the PHP web language. What I would say the “best way” involves editing either original or Child Theme functions.php file. Therefore it is bit risky and you could potentially take your side down in an event of an incorrect implementation. Let’s look at the fool safe “easy way” first.

By creating a page template

The advantage of this method is that we are not editing your original or Child PHP theme files. Instead, a separate PHP file is created (either directly on the server or outside then uploaded using FTP) as a template file. This may also potentially create coding conflicts but usually can be resolved by simply removing the newely created file from the server. This new template must be located in the templates folder of your WordPress theme files. Hence the location should be the same as the page.php file location. Usually it is in “themes” folder.

First, create a PHP file with a desired name. Let’s call this file “template-random.php” in this particular example.

<?php
/* Template Name: Random Item */
query_posts(array('orderby' => 'rand', 'showposts' => 1));
 if (have_posts()) :
   while (have_posts()) : the_post(); ?>
     <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
     <?php the_content(); ?>
   <?php endwhile;
 endif; ?>

After creating the template go to the Admin Panel of your WordPress and create a new page (let’s call it “random”). Choose the template we just uploaded as the template of the page. The template we just created should appear on the list of selectable templates under “Attributes” pane as “Random Item”. A random page/post will be generated every time this new random page is generated. For example, sanuja.com/blog/random will give you a random item from the database. Now you can use “a href” type links or buttons to direct users to random pages.

By updating the functions.php

Update the functions file in your main theme files or Child Theme files with the following code.

function le_random_post() {
if ( isset( $_GET['random'] ) && $_GET['random'] == 1 ) {
   $posts = get_posts( 'post_type=post&orderby=rand&numberposts=1' );
      foreach( $posts as $post ) {
      $link = get_permalink( $post );
      }
      wp_redirect( $link,307 );
   exit;
       }
}
add_action( 'template_redirect','le_random_post' );

Now you are done! Just use the appropriate URL to generate items from this script. For example, this will generate a random item as soon as the URL, http://sanuja.com/blog/?random=1 is requested.