Thursday, November 21, 2013

Storing the Total Number of times a Page is viewed

A quick one on how to do a page view count on your site using php.
The code below can be manipulated to achieve other objective depending on your level of understanding on how the code works, it is straight to the point, all you need do is to create a database e.g named PageView  using PhpMyAdmin and run the SQL below to generate your table the create a new php page and insert the code PHP bellow that is all. run the the page and see what happened and also refresh PhpMyAdmin and see the inserted records including the page URL itself.
if this information do help you do remember to leave a comment or subscribe for more. 
SQL:

REATE TABLE IF NOT EXISTS `views` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `page` varchar(150) NOT NULL,
  `datetime` datetime NOT NULL,
  `newsid` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=28 ;

PHP
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conn = "localhost";
$database_conn = "
PageView";
$username_conn = "root";
$password_conn = "root";
$conn = mysql_connect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);
?>


<?php
if (isset($_SERVER["SCRIPT_NAME"])){
mysql_select_db($database_conn, $conn);
$query2 = "INSERT INTO views (page, datetime,newsid) VALUES ('".$_SERVER["SCRIPT_NAME"]."', CURDATE(), '$_SESSION[newsid]')";
$result2 = mysql_query($query2,$conn);

$query3="SELECT COUNT(*) as total FROM views WHERE newsid='$_GET[newsid]'";
$result3=mysql_query($query3,$conn);
while($data=mysql_fetch_array($result3)){
    $count = $data['total'];
}
}

 echo $count;
?>

Wednesday, November 20, 2013

Multiple Drop-Down Select Lists Creator

Multiple Select Dropdown List with AJAX

This tutorial presents an AJAX script that can be used to create dynamically multiple Select lists with data from a MySQL table.

First, a single select list is displayed on the page, then when the user chooses an option, it calls an Ajax function that acceses a PHP file that will return a select list according to the option selected. The Ajax function receives and displays the second select list.
When the users selects an option from the second select list, this script can display a third list of options, according to the options selected in the first an second select lists.

The script contains two files, a PHP file (named "select_list.php") with the code that selects data from a MySQL table and returns a select drop down list, and a JS file (named "ajax_select.js") with the Ajax code that accesses the PHP file.
You can copy and use the code for these files displayed below, or download the files from: Script Multiple Select Dropdown List

Check out this resource: http://coursesweb.net/scripts/select_lists_creator/create_select_lists.html

Tuesday, November 19, 2013

Dowloadable link File Upload without Refreshing (Reloading of Page)

http://tuts.wtfdiary.com/2012/06/file-upload-in-php-without-refreshing.html

Friday, November 8, 2013

URL parameters value encryption/decryption using MD5 to Authenticate value stored in database field

You can create a hash of the id so you get something like:
 
http://www.demo.com/displaycommittees.php?id=81dc9bdb52d04dc20036dbd8313ed055

In you db query you can do a select on the users table including a WHERE statement that also hashes the id column like:
 
WHERE MD5(id) = $_GET[id]

A side note to this is that MD5 hashes do not necessarily have to be unique. So you cannot be sure that this select statement is always returning the row you wanted. 

This works fine and i have always applied this algorithm. for instance assuming the actual value of the encrypted id 23, if you try to put 23 in place of the encrypted code it will not work( no result will be display).

Thursday, November 7, 2013

HOW TO REMOVE THE COMMENTS (LEAVE A COMMENT) IN WORDPRESS PAGES



STRAIGHT TO THE POINT

Step 1: Login into Wordpress as Admin.

Step2: Under Appearance Section, Click on Editor.

Step 3: Look to your extreme right under Template and Click Page  Template (page.php).

Step 4:  Look for  <?php comments_template(); ?> and uncomment it like this <!-- <?php //comments_template(); ?>--> that is all.

Step 5: Then Click on Update File to complete the process, go back to your page and refresh.

If you know this Article or post helps do comment.

Monday, November 4, 2013

HOW TO DE-ACTIVATE THE WORDPRESS ADMIN-BAR




Step1: Open the WordPress Folder/Directory
Step2: Open the wp-includes folder/Directory
Step3: Open the admin-bar.php file and uncomment the following lines out as seen below.
/*if ( is_user_logged_in() ) {
                                // Add "About WordPress" link
                                $wp_admin_bar->add_menu( array(
                                                'parent' => 'wp-logo',
                                                'id'     => 'about',
                                                'title'  => __('About WordPress'),
                                                'href'  => self_admin_url( 'about.php' ),
                                ) );
                }

                // Add WordPress.org link
                $wp_admin_bar->add_menu( array(
                                'parent'    => 'wp-logo-external',
                                'id'        => 'wporg',
                                'title'     => __('WordPress.org'),
                                'href'      => __('http://wordpress.org/'),
                ) );

                // Add codex link
                $wp_admin_bar->add_menu( array(
                                'parent'    => 'wp-logo-external',
                                'id'        => 'documentation',
                                'title'     => __('Documentation'),
                                'href'      => __('http://codex.wordpress.org/'),
                ) );

                // Add forums link
                $wp_admin_bar->add_menu( array(
                                'parent'    => 'wp-logo-external',
                                'id'        => 'support-forums',
                                'title'     => __('Support Forums'),
                                'href'      => __('http://wordpress.org/support/'),
                ) );

                // Add feedback link
                $wp_admin_bar->add_menu( array(
                                'parent'    => 'wp-logo-external',
                                'id'        => 'feedback',
                                'title'     => __('Feedback'),
                                'href'      => __('http://wordpress.org/support/forum/requests-and-feedback'),
                ) );*/
Step4: Save then Refresh you site that is all.