A problem with float and clear that drove me crazy!

Yesterday i had submitted this wordpress theme of mine to the official wordpress theme directory. I got a feedback from the guys there stating that my theme wasnt valid as it had some issues and they asked me to fix them and upload again. I was able to fix all the issues but one, ant that was : the gallery, when inserted in the post, streches out the gallery container div to around 600px! I looked at the source code of the gallery and found that the gallery was created using the dt and dl tags, and the dt containing the images was set to float to left using css and each row of dt containing images was separated out by a br styled to clear:both. This was the part of document which was causing trouble, the br tag, after clearing both side was pushing down the next row of images to at least around 600px, trying to fix this issue only had me panicking after hours of debugging,re-writing some styles and googling the solution out, but in vain :( . It was when i was almost exhausted and felt like my brain was going to give up and shutdown that i told myself to give it a last try , i just gave my content div (which was set to float to left and was the parent of the post div that was streching out) a fixed width of 740px, and hurray, to my amazement i found that the problem was solved!!! :D . I dont know what actually happened, what had the width of the parent element to do with the vertical stretchning of the gallery image rows. So if you have an explanation then please lemme know in the comments below.

Drive your php code viewers mad! Encode your php script

If you are among the ones who give away free self written php scripts to everybody but want some way to stop script kiddies and newbies just copy-pasting and modifying your script or you just dont want code newbies to know the original code then this post is probably for you. The trick is to encode your php code as a string and then parse the encoded string as php code after decoding it. This trick is very commonly usede by developers. Though this trick cannot stop code copying but can discourage the viewer to a certain extent to copy the code.
Here is how to do it:

  1. Encode your code as string using any encoding method/functions . the most commonly used is base64_encode. You can even use Dynamicguru’s Online base 64 encoder and decoder to instantly convert your code to base64 format
  2. In your script file, decode the generated string using base64_decode function and assign it to a variable
  3. Now call the function eval() passing your decoded string as argument and you are done!

Example :

Consider the following piece of code :

<?php
echo "hello world";
?>

Now suppose you want to disguise the code and make it look un-interpretable , Encode it using our Online base 64 encoder and decoder . here is what the code looks like after encoding :

PD9waHANCmVjaG8gXCJoZWxsbyB3b3JsZFwiOw0KPz4=
//Amazing isnt it?

Now call the eval() function :

eval(base64_decode("PD9waHANCmVjaG8gXCJoZWxsbyB3b3JsZFwiOw0KPz4= "));

//the above code is equal to :

<?php
echo "hello world";
?>
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Note
This trick should not be used if you want to completely disguise your code, as anybody can go a step further and decode it using base64_decode function.

The eval fucntion evaluates a string as a php code and is of immense help in situations where you want a piece of code to be stored in a file / database and executed at a later time

hope you enjoyed the post and learnt something new and useful :D

Another wordpress theme

Free beautiful wordpress theme

Free beautiful wordpress theme


Here is another free beautiful wordpress theme from dynamicguru.com . This theme uses jQuery effects for a nice hover effect on the links in the sidebar.

Download this free Wordpress theme

UPDATE 17/06/09

An updated an improved version (1.3) of this theme is now available for download at the official wordpress theme directory :
http://wordpress.org/extend/themes/silver-dreams


To install wordpress theme :

  1. Download and unzip the theme file
  2. Upload the theme directory to “wp-contents/themes” directory
  3. If you do it right, the theme preview will be visible in “Themes”, Click on it to activate and enjoy!

PHP contact form script

The most common use of php on the internet is probably to make Contact Forms or mail forms . Here is a free php contact form script that takes input from 5 fields : name,email,url,subject and message. The script also validates the input and checks to see if the name , email and message fields are filled out properly and also checks if the email address provided is valid. the script then sends a mail to the administrator containing the message and the visitor info and also writes (appends) the input to a “contact.log” file . The script is quiet easy to understand and edit as it is commented and well written. Just place the following code in a “contact.php” file and change the value of $admin_mail to your email id. You can style the form to your taste using css.

<?php

error_reporting(0);
        //Replace with your email ID
        $admin_mail="mujtaba_91@yahoo.com";
       
if (isset($_POST[‘button’])) {
        $date=date(‘l dS \of F Y h:i A e’);
        $name=htmlentities($_POST[‘name’]);
        $email=htmlentities($_POST[‘email’]);
        $url=htmlentities($_POST[‘url’]);
        $subject=htmlentities($_POST[’subject’]);
        $message=htmlentities(stripslashes($_POST[‘message’]));
        //Form Validation
        $errors="";
        if(empty($name)) {
                $errors.="Please enter your name <br />";
        }
       
        if(empty($email) || !strpos($email, "@") || !strpos($email, ".")) {
                $errors.="Please enter a valid email ID <br />";
        }
       
        if(empty($message)) {
                $errors.="Please enter a message <br />";
        }
       
        if(!empty($url) && !strpos($url,"http://")) {
                $url="http://".$url;
        }
       
       
        //Building mail if the input is valid
       
        if ($errors=="") {
        $mail_subject="Message from :".$email;
         //Required for html formatted mail, do not remove
        $headers  = ‘MIME-Version: 1.0′ . "\r\n";
        //Required for html formatted mail, do not remove
        $headers .= ‘Content-type: text/html; charset=iso-8859-1′ . "\r\n";
        $headers .= "To: Admin <".$admin_mail.">" . "\r\n";
        $headers .= "From: ".$name." <".$email.">" . "\r\n";
       
        //The mail
        $mail_message="
        <html>
        <head>
        <title> Message from "
.$name." </title>
        </head>
        <body>
        <b>Name</b> :<br /> $name <br />
        <b>Email</b> :<br /> $email <br />
        <b>URL</b> :<br /> <a href=\"$url\">$url</a> <br />
        <b>IP Address</b> : <br/>
        "
.$_SERVER[‘REMOTE_ADDR’]." <br />
        <b>Date and Time</b> : <br />
        $date <br />
        <b>Message</b> :<br/> "
.nl2br($message)."
        </body>
        </html>"
;
       
        if(mail($admin_mail,$mail_subject,$mail_message,$headers)) {
                $status="Mail Sent Successfully";
                //echo "<div class=’success’>$status</div>";
        }
        else {
                $status="Mail Failed to Send";
                //echo "<div class=’error’>$status</div>";
        }
       
        //Logging the message to a file
        $file="contact.log";
        $log_message="
        Name : $name\r\n
        Email : $email\r\n
        URL: $url\r\n
        Subject: $subject\r\n
        Time: $date\r\n
        IP Address: "
.$_SERVER[‘REMOTE_ADDR’]."\r\n
        Message:
$message\r\n
        Mailing Status: $status\r\n
        _______________________________________________________________________\r\n
        "
;
        $fh=fopen($file,"a+");
        fwrite($fh,$log_message);
        fclose($fh);
       
        echo "Thanx! i will get back to you soon";
        }
        else {
                echo $errors;
        }

       
}

else {
        echo "
        <form action=\"contact.php\" method=\"post\" id="
myform" >
        <input type=\"text\" name=\"name\" /> Name <br />
        <input type=\"text\" name=\"email\" /> Email <br />
        <input type=\"text\" name=\"url\" /> URL <br />
        <input type=\"text\" name=\"subject\" /> Subject <br />
        <textarea cols=\"30\" rows=\"20\" name=\"message\" ></textarea>
        <input type=\"submit\" name=\"button\" value=\"Submit\" />
        </form>"
;
}
?>

My first web portfolio

The web portfolio of Mujtaba Ahmed

The web portfolio of Mujtaba Ahmed

Today i’ve launched my new website and my first web portfolio.

You can check it out here: www.dynamicguru.com/mujtaba/ .

The site is one of my best works till date and is the first site of mine to use ajax and is powered by jQuery. The site uses awesome jQuery effects for page transitions. Also it has validated XHTML 1.0 Strict markup. Check it out and tell me in the comments what you think about it?

Learning jQuery

jQuery is a comprehensive free javascript library that is a must for every designer and developer. It is extremely powerfull and very easy to learn and use and saves a developer a hell lot of time. It can be used to build powerful interactive User Interfaces and sites.You can take a look at some awesome sites built using jquery at jQueryStyle.com to better understand what this little wonder library is capable of.
The library was first written by John Resig back in 2006. The current realease version at the time of writing is 1.3.2. Due to its DOM centered approach, jQuery is very easy to learn for a person who already has some css and xhtml background.
You can download your copy of jQuery from the homepage of jQuery.com
There are a number of free resources on the web which teach you jQuery right from the start, but i would recommend LearningJQuery as it is well documented and has three separate sections for beginner,intermediate and advanced levels. LearningJQuery is authored by Karl Swedberg and some other authors. it is a good place to start with for people new to jQuery. Also the jQuery Docs is good place to refer to whenever you find yourself stuck with a problem.

Why not to rely on free web hosts?

I launched Scrapground.co.cc around an year ago when Orkut enabled html scraps. The site was my first project as i had just taught my self css and php. It featured an online “scrap creating tool” which designed your scrap in 40 different html templates and all you had to do was copy and paste the code given below any template into your friends scrapbook. The site was hosted for free at www.x10hosting.com and had a free .co.cc domain. It worked fine untill i moved to India and stopped logging in into my hosting account frequently, i got suspended a couple of times for inactivity and last week i found out to my surprise that my hosting account had been terminated for inactivity!!! I lost both of my sites as i didnt have a backup of it on my local machine!!! :(

The lesson i learnt were : Never rely on free webhosts and if you cant do without a free host Take regular backup of your site so even if you are kicked off the hosting service you can still quickly switch to another free host.

There are even more reasons as to why free hosts are highly un-reliable, like:

  • Limited or low bandwidth
  • Limited or very less web space
  • Frequent server downtimes
  • No or limited customer support
  • Lack of freedom/ restrictions
  • Search Engines ignore you

Silver Simplicity – Free gorgeous light weight wordpress theme

Hey fellas, this is the first free wordpress theme from www.DynamicGuru.com . Its light weight,uses minimum images and is beautiful

screenshot

Download the following .rar file, unzip it and upload the files to your theme directory and activate it from Dashboard->Appearance (themes)

Click here to download this wordpress theme

Free blue powerpoint template

Here is yet another free powerpoint template from us. The file includes two slides and is in .pot (powerpoint template) format. Download and enjoy.

PREVIEW:

blue_pot_template

Click to download free beautiful powerpoint template

Creattica – best design inspiration site

Every designer, at the start of his career, needs some inspiration, i mean great ideas dont simply come out of nowhere in a beginners mind. We all have been or are copiers, we need some push in the right direction, some ready examples of great design work really boosts up our own creativity level, this is exactly what inspiration sites do, and www.creattica.com is my most favourite site for inspiration. It features thousands of user submitted photoshop artwork, beatiful web designs and impressive business cards. So if you are one of those looking for some great examples to learn from (not to copy from) then make sure you visit www.creattica.com.

How to write browser specific css

Usually when it comes to browser specific css we often mean IE specific code. You might be aware of the conditional comments tag you can use to target different versions of Internet Explorer. But 2day i’ll be showing you a much simpler way to tame IE 6 and 7 to your needs . Lets suppose for some reasons you want a div to have a height of 10px in all browsers, but a height of 12px in IE 7 and 15px in IE 6, here is how it can be done without the use of conditional comments:

div {
//for all browsers
height:10px;

//for IE 6,others will ignore this
_height:15px;

//for IE 7
*height:12px
}

isnt it much simpler than writing conditional comments?
The same technique can be applied to other properties as well. You can even use this hack to request your IE 6 users to upgrade to a modern browser,how? Just make a div and write your message in it and set its “display” to “none” while set “_display” to “block”.This will simply tell all browsers not to display the div while IE 6 will. Hope you enjoyed the post.

Javascript quadratic equation solver

Here is a simple javascript that solves quadratic equations of the form ax²+bx+c = O. You just have to specify the values of a ,b and c and the script then calculates the two real roots alpha(x1) and beta (x2)  of the equation. The script also tells you if the equation has a real root or not, depending upon the value of D (Discriminant). The equation is solved using the quadratic formula x = -b±(b²-4ac)½/2a .
The script is located here ->http://www.dynamicguru.com/files/quadratic_equation.html

Here is the source code of the script :

//Place this within the  section <script type="text/javascript">< function calculate()     {      var a=prompt("enter value of a");      var b=prompt("enter value of b");      var c=prompt("enter value of c");      var a2=2*a;      var ac=4*a*c;      var dis=b*b;      var dis=dis-ac;      if(dis<0){         document.getElementById('Equation').innerHTML='No real roots exist since Discriminant < 0 !<br />D = ' + dis + ' <br />The Equation = ' + a + 'x&#178; + ' + b + 'x + ' + c + '<br />';         document.getElementById('x1').innerHTML='&nbsp; ';         document.getElementById('x2').innerHTML='&nbsp; ';         }      else{         var dis_sqrt=Math.sqrt(dis);         var x1=-b+dis_sqrt;         var x1=x1/a2;         var x2=-b-dis_sqrt;         var x2=x2/a2;         document.getElementById('Equation').innerHTML=" Equation = " + a + "x&#178; + " + b + "x + " + c + "<br />";         document.getElementById('x1').innerHTML=' Alpha (x1) = ' + x1;         document.getElementById('x2').innerHTML=' Beta (x2) = ' + x2;         }     } </script> //Place this within the section: <h1><a onclick="calculate()" href="#"> Click to solve »»</a></h1>     <div id="Equation"></div>     <div id="x1"></div>     <div id="x2"></div>

.htaccess – A quick guide

.htaccess , Whats is it?

According to Apache:

.htaccess files (or “distributed configuration files”) provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof

‘Directives’ usually refer to the commands that are contained in the .htaccess files, which control or modify your server’s various behaviours. Many free and paid web hosts permit you to change and modify your .htaccess files but remember if you have a website running on Yahoo Geo Cities,Goolge sites or freewebs then this article is meaningless for you cause they dont allow access to .htaccess files

What can you do with .htaccess?

.htaccess can be used in many different creative ways , but its most common usage is for:

  • Setting up custom 404 error pages
  • Enable/Disable directory browsing
  • Change default homepage for a directory
  • Block certain users from accessing your site
  • Block specific refferers
  • Prevent certain files from being viewed
  • Block Hotlinking

How to create one?

Create a text file from any text editor, Note Pad,Text Pad and save it as .htaccess ( remember the period before htaccess and no .txt extension ).
Upload it in your home directory…The rules in .htaccess file apply to all the sub directories in your files directory

Doing some cool stuff

Now here comes the real thing…
To enable your server to use a custom 404 file not found page for broken links or URL typos…
include the following code in your .htaccess file:

#The page notfound.html should be in the same directory as your .htaccess ErrorDocument 404 /notfound.html #Alternatively you can specify just raw html to be used instead of a page ErrorDocument 404 "<h1>yikes! that  page passed away a while ago...</h1>"

Enable / Disable directory browsing

Options +Indexes
## Block some specific file types from showing
IndexIgnore *.avi *.mp3 *.pdf


Change directory homepage

##the pages are used in order
DirectoryIndex myhomepage.html index.html index.php

Block some users from accessing your site

<limit GET POST PUT>
order deny,allow
deny from 202.54.122.33
deny from 8.70.44.53
deny from .hackers.com

allow from all
</limit>

Display your visitors IP address using php

The following line of code shows your visitors their IP address,

<?php echo $_SERVER['REMOTE_ADDR'] ?>

For knowing what all super globals are available for you use the function phpinfo(); or print the complete $_SERVER array using print_r($_SERVER);

Generate HTML formatted scraps via Scrapground.co.cc


Do you use Orkut?
If so then you might be loving sending fun, html formatted scraps…
here is a little tool that creates your scrap in beautiful 44 different templates:
http://www.scrapground.co.cc
the same tool is also featured at http://www.cluborkut.co.cc
Just enter your scrap and hit enter, copy and paste the source code generated….and have fun :-)

Update :
Scrapground.co.cc and Cluborkut.co.cc are no more ! :(
my free hosting accounts got terminated for inactivity…

Get a free domain with top class free web hosting!

Are you a desperate blogger/webmaster stuck with your free webhost where server crashes thrice a day and a freedomain that is ignored by search engines? Are you looking for free domain with free hosting but dont know where to go? Well then BuddingBloggers is the right thing for you. BuddingBloggers ,as the name suggests is helpful for growing bloggers who dont have a domain of their own. Now you might be wondering what maybe the procedures or criteria for getting a free domain via this service, well the good news is, BuddingBloggers doesnt require you to put some work into it or first complete some sponsored criteria(s) or purchase any service to be liable to recieve a freedomain( as other free domain services do) .Instead ,BuddingBloggers is completely free without any hidden costs, all you gotta do is fill out the application form here : http://buddingbloggers.com/apply and if you are lucky and enough you might get selected for the sponsorship program.but brfore make sure you have read and understood the program guidelines which you can find here : http://buddingbloggers.com/blog/program-guidelines/

Cheers and happy blogging! :)

Free RED beautiful powerpoint template

Download free powerpoint template

Download free powerpoint template

This beautiful free powerpoint template comes ready with two slides with awesome vista-like background.

Just download and make that beautiful impressive presentation

Download Free powerpoint template

How to change cursors on web pages

The “cursor” property of css allows you to change the mouse cursor either for the complete page or for specific elements

The following example illustrates the use of the “cursor” property of css:

//This changes the cursor for the complete page body { cursor:url(cursor.cur); } //This changes the cursor only for the element of class fancy .fancy{ cursor:url(fancy_cursor.ani); }

Cursors are files with extension .cur or .ani (for animated cursor ),there are many sites which give you free animated and non animated cursors for download, even there are freewares which let you create your own custom cursors.
Furthermore, instead of specifying the url of the cursor file you can specify the type/style of cursor which comes inbuilt on most systems.

For example, cursor:pointer will cause the cursor to change to a pointer (as on hyperlinks) and cursor:help will give you a small question mark.

Below is a complete list of the cursor types you can use, move the cursor over a word to see it change

Auto

Crosshair

Default

Pointer

Text

Wait

Help

Move

E-resize

N-resize

NW-resize

SE-resize

SW-resize

S-resize

W-resize

© 2010 Dynamic Guru All rights reserved — About UsContactMujtaba