Change background of a row OnMouseOver

If you want to have the entire row/block to change the background color OnMouseOver, follow the instruction below.

Step 1: Add 2 new classes in your style.css file. 1 class is “change_bg” which will behave when Mouse moved Over a row in a table. The other is “white_bg” which will behave when Mouse moved Out of that row.

Step 2: Add the following codes to a row in the table or a <div> that you want it to change the behavior.

<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”5″>
<tr onmouseover=”this.className=’change_bg'” onmouseout=”this.className=’white_bg'” >


Show or hide the page title in WordPress

Many of you have asked me a question how you hide the page title in WordPress, for example Home page. Some people don’t like to show the word “Home” right on frontpage. I tell you what; it’s not that difficult if you know how classes and functions work in this system. So this is what you should do to hide the title of the frontpage.

step 1) Go to directory /wp-includes/ in the root directory

step 2) Edit the function called function the_title($before = ”, $after = ”, $echo = true) in the file post-template.php

That’s it. You’re done. The rest will be taken care by HTML template of your selected theme.


How to block spam posts in your online forum

Most of you who own an online forum have already known much about spammers are trying to add bad posts, posts of links to porn websites, links to drugs, etc. I’m so tired of those who don’t respect my forum. So today, I’m gonna give you an instruction who to restrict those posts from entering to your professional forums. Since I added this logic in my online forum, I never see any bad post in the database any more.

Go to your forum root directory, pick the file called posting.php. First of all, you got to create a table of credible users in your database, example table is named tbl_users. The fields include just id (required), username (required), date_joined (optional). That’s all you need. Then copy my codes below and paste them to line 28 of your posting.php file. Remember to change the table “tbl_users” to the user table name in your database. The codes below will display a message and exit when there’s a user trying to post bad post to your forum. It only allows users who are credible (real users) in your tbl_users table.

//start
$aw_id = 0;
$getuser = $user->data[‘username’];
// check this username if it matches the username in separate member database to prevent hackers who post junks to your forums

$sql = “SELECT User_ID
FROM member_database.tbl_users
WHERE User_Name = ‘$getuser'”;

$result = $db->sql_query($sql);
$this_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

$aw_id = $this_data[‘User_ID’];
if($aw_id == ” || $aw_id == 0){
$box_t = ‘<div align=”center” style=”margin-top:50px;”><table cellpadding=”20″ style=”border:5px #027ab7 solid; background: #ecf3f7;”><tr><td>’;
$box_b = ‘</td></tr></table></div>’;
$message = ‘Our forum is only for licensed users. Please login to <a href=”http://www.yourdomain.com/login/”>www.yourdomain.com</a> and click on Forum icon to start posting a reply or a new topic.’;

exit(“$box_t$message$box_b”);
}
//end

The logic above has been tested on Windows and Linux servers. If you have issue implementing my codes, please call me at 1-415-845-0248 (Binh) I will help you after my working hours.


How to Execute an HTML Form Using JavaScript

Most of websites nowadays have at least one form. In general, the form is executed when a user presses a submit/send button. However, sometimes, you may need to submit the form programmatically using JavaScript without the interaction of a user. User wouldn’t even know because the JavaScript executes in the back-end.

JavaScript provides the form object that contains the submit() method. You will have to use the id or name of the form to get the form object.

For example, if the name of your form is ‘thisform’, the JavaScript code for the submit call is:
document.forms["thisform"].submit();

Here is the code to submit a form when a hyperlink is clicked:

<form name=”thisform” action=”process_form.php” method=”post”>
Search: <input type=’text’ name=’query’ />
<a href=”javascript: submitthisform()”>Search</a>
</form>
<script type=”text/javascript”>
function submitthisform()
{
document.thisform.submit();
}
</script>


What debugger is used to debug Drupal?

Since I’m working on module development and deals with so many websites during my projects, I found Xdebug is a great tool to debug Drupal modules. I am listing here step by step process to debug drupal using xdebug and Eclipse with your WAMP.

Download Eclipse PDT from here http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/…

Download php_xdebug-2.0.4-5.2.8.dll dll and place in C:\wamp\bin\php5.2.6\ext directory

Edit your php.ini file with the following code at the end of file.
[xdebug]
zend_extension_ts=”C:\wamp\bin\php5.2.6\ext\php_xdebug-2.0.4-5.2.8.dll”
xdebug.remote_enable=1
xdebug.remote_host=”localhost”
xdebug.remote_port=9000
xdebug.remote_handler=”dbgp”

Note: Carefully check the path and PHP version you’re using on zend_extension_ts line above.

Restart WAMP server.

If it’s successful installation of xdebug, when you view phpinfo.php, you will find the lines below:

Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with Xdebug v2.0.4, Copyright (c) 2002-2008, by Derick Rethans

Open your Eclipse and add the drupal folder as php project. Todo this just create an emty php project and give the project workspace as c://wamp/www and add import your existing drupal folder to this project as a general folder import in eclipse.

Open Window->Preferences->General->Web Browser and set your browser as external browser and select any of your browser.

Then go to Window->Preferences->PHP->Debug, set PHP Debugger option to XDebug

Next select your index.php -> right click -> Debug as -> Php webpage. Now your defined browser will open and you can see your project is running.

Now go to Window -> open Perspective -> PHP debug. You can see code is halted at first line of code. If you press play button in green color, your codes will execute.

Set break points wherever you want in the files and click on step into to see the code flows.

To make module files open in Eclipse, you must add extensions to *.module to window->preferences->general->editors->file associations file type such as *.module, *.engine, *.inc and associated editor as PHP

Please leave a comment for this article if you encounter any issue during the installation and debugging. I hope that this article helps you.