Free Code Collection

Avoid automatically post form via CAPTCHA

by Hussain on Jul.26, 2009, under PHP

A good way to avoid automatic form submissions when creating a web form is to add some kind of verification. One of the best ways is to use an image verification, called also captcha. What it does is to dynamically create an image with a random string displayed on it. Then visitor is asked to type that string in a text field and once the form is submitted it checks if the string on the image matches the one inputted by the user. Because there is no easy way to read a text from an image (image recognition) this is a good way to protect your web forms from spammers.
For doing this CAPTCHA I would suggest using a session variable where you store the string generated and displayed on that dynamically generated image.
 MySQL |  copy code |? 
1
CREATE TABLE `comment` (
2
`name` varchar(50) collate latin1_general_ci NOT NULL,
3
`mail` varchar(50) collate latin1_general_ci NOT NULL,
4
`url` varchar(50) collate latin1_general_ci NOT NULL,
5
`comment` longtext collate latin1_general_ci NOT NULL
6
)
Create a page comment.php and create form for post comments:
 HTML |  copy code |? 
01
<form name=”commentform” action=”comments-post.php” method=”post” id=”commentform”>
02
<table width=468? border=0? cellspacing=3? cellpadding=3?>
03
<tr>
04
<td width=103?>Name</td>
05
<td width=344?><input name=nametype=textid=nametabindex=1? value=" size=”18? /></td>
06
</tr>
07
<tr>
08
<td>Mail</td>
09
<td><input type=textname=”email” id=”email” value=" size=”18? tabindex=”2? /></td>
10
</tr>
11
<tr>
12
<td>URL</td>
13
<td><input type=textname=”url” id=”url” value=" size=”18? tabindex=”3? /></td>
14
</tr>
15
<tr>
16
<td>Enter Number </td>
17
<td><input name=”txtNumber” type=textid=”txtNumber” value=" tabindex=”4?/>
18
<img src=”randImages.php”/></td>
19
</tr>
20
<tr>
21
<td>Comment</td>
22
<td><textarea name=”comment” id=”comment” cols=45? rows=9? tabindex=5?></textarea></td>
23
</tr>
24
<tr>
25
<td>&nbsp;</td>
26
<td><input name=”save” type=”submit” class=”submitbutton” id=”save” tabindex=5? onClick=”MM_validateForm(name’,”,’R',’email’,”,’RisEmail’,'comment’,”,’R');return document.MM_returnValue” value=”Submit Comment”/></td>
27
</tr>
28
</table>
29
</form>
Now we will create a Image Verification Page which will show Random Images, Save this page as randImages.php.
 PHP |  copy code |? 
01
session_start();
02
// $Rand Function generate 5 digit random number starting 10000, 99999. You can Edit it as your required.
03
$rand = rand(10000, 99999);
04
// create the hash for the random number and put it in the session
05
$_SESSION['image_random_value'] = md5($rand);
06
// create the image
07
$image = imagecreate(60, 30);
08
// use white as the background image
09
$bgColor = imagecolorallocate ($image, 255, 255, 255);
10
// the text color is black
11
$textColor = imagecolorallocate ($image, 0, 0, 0);
12
// write the random number
13
imagestring ($image, 5, 5, 8, $rand, $textColor);
14
// send several headers to make sure the image is not cached
15
// taken directly from the PHP Manual
16
// Date in the past
17
header(”Expires: Mon, 10 April 2008 05:00:00 GMT”);
18
// always modified
19
header(”Last-Modified:. gmdate(”D, d M Y H:i:s”) . ” GMT”);
20
// HTTP/1.1
21
header(”Cache-Control: no-store, no-cache, must-revalidate”);
22
header(”Cache-Control: post-check=0, pre-check=0?, false);
23
// HTTP/1.0
24
header(”Pragma: no-cache”);
25
// send the content type header so the image is displayed properly
26
header(’Content-type: image/jpeg’);
27
// send the image to the browser
28
imagejpeg($image);
29
// destroy the image to free up the memory
30
imagedestroy($image);
31
?>
32
Now Create a page which insert the comment data.
33
session_start();
34
//Enter here your php mysql connection details
35
if(isset($_POST['save'])){
36
$name=$_POST['name'];
37
$email=$_POST['email'];
38
$url=$_POST['url'];
39
$comment=$_POST['comment'];
40
}
41
$number = $_POST['txtNumber'];
42
if (md5($number) == $_SESSION['image_random_value']) {
43
$sql=”INSERT into comment(name, mail, url, comment) values($name,$email,$url,
44
$comment);
45
$result=mysql_query($sql) or die(’Can not Add Your Comment’);
46
echo “Your Comment have been added. Returning To Write Return page here. Please wait…”;
47
$_SESSION['image_random_value'] =;
48
}
49
} else {
50
echo ‘Sorry, wrong Image Varification Number. Please try again’;
51
}
52
?>
  • Share/Save/Bookmark
Leave a Comment :, , , , , more...

OpenText Online – OpenText’s new site

by Hussain on Jul.07, 2009, under OScript

Open Text Online

Open Text Online



Recently OpenText re launched their latest website OnLine.OpenText.Com ,which is on the surface a revamped version of their old Communities website, but the new site has much more to offer. In this article we shall take a short tour around the site and uncover some of the hidden gems.
Some of you may be asking why another website is needed when you already have the OpenText corporate site, the always useful Knowledge Centre or KC, its IXOS equivalent the ESC, and the showcase of new functionality that is FirstLook ? The sites History & Aims page explains that the site is designed for the Livelink users in any organisation where as the Corporate site is more for investors and new customers and the KC is more for existing support staff and developers, OnLine, they say, is there “to help our users get the most out of our products”. It also provides a starting point for people to move into the other OpenText websites as they need to as well as promoting awareness of them.

What is there inside OnLine that may be of interest ? My personal favourite is the Blogs section, which contains blogs from OpenText staff as well as some of the ’seasoned livelink veterans’ from the user community who have been awarded the title of Global Star ECM Champions as part of the Global Star program. It is in this latter section that my own personal blog can be found. Some of the key luminaries that you may have heard of such as Martin Sumner-Smith (VP Customer Partnership), Tammy Jakubowski, formerly McMahon (User Research Engineer) and David Slimmon (Knowledge Manager and KC Admin) are among the OpenText staff contributing to personal blogs, on the other side of the fence we have the likes of Stephen Fisher, Eric Slaghuis and myself among many others giving our thoughts and comments on Livelink and the universe in general. There is plenty to learn and read in these, some is Livelink related and contains many useful tips & tricks, additionally there are many postings on wider topics such as usability, meta data and how to use technology to benefit your organisation.

As well as the Blogs, there are also a small number of Discussion Forums which are more aimed at the non-technical aspects of Livelink such as keeping a user community interested and excited about Livelink as well as some general forums to support the OnLine site. At present, there is not as many forums, or posts, as there are in the KC, but given time I hope that the breath and number of them will increase.

In conclusion, I think that OpenText OnLine has the potential to become a great addition to the OpenText suite of websites and offer something distinct and different from the existing sites. As previously mentioned the site is based on the Livelink Communities of Practice (CoP) product, and there is one thing a community needs its people taking part, so join now and participate

source: (http://www.greggriffiths.org/livelink/editorial/online.html)
  • Share/Save/Bookmark
Leave a Comment :, , , more...

[jQuery] changing default thickbox behavior

by Hussain on Jul.05, 2009, under Developers, JQuery

To prevent closing by clicking on the overlay and remove the ‘close’ link
(better IMHO than just disabling it), remove line 38:
$("#TB_overlay").click(TB_remove);

remove the TB_closeWindow <div> from line 133:
$("#TB_window").append("<a href=” id=’TB_ImageOff’ title=’Close’><img
id=’TB_Image’ src=’"+url+"’ width=’"+imageWidth+"’ height=’"+imageHeight+"’
alt=’"+caption+"’/></a>" + "<div id=’TB_caption’>"+caption+"<div
id=’TB_secondLine’>" + imageCount + prev.html + next.html + "</div></div>");

remove line 135:
$("#TB_closeWindowButton").click(TB_remove);

remove the TB_closeAjaxWindow <div> from line 205:
$("#TB_window").append("<div id=’TB_title’><div
id=’TB_ajaxWindowTitle’>"+caption+"</div></div><iframe
frameborder=’0′
hspace=’0′ src=’"+urlNoQuery[0]+"’ id=’TB_iframeContent’
name=’TB_iframeContent’ style=’width:"+(ajaxContentW +
29)+"px;height:"+(ajaxContentH + 17)+"px;’ onload=’TB_showIframe()’>
</iframe>");

and 207:
$("#TB_window").append("<div id=’TB_title’><div
id=’TB_ajaxWindowTitle’>"+caption+"</div></div><div
id=’TB_ajaxContent’
style=’width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;’></div>");

remove line 210:
$("#TB_closeWindowButton").click(TB_remove);
and remove lines 258-259:
$("#TB_overlay").unbind("click");
$("#TB_closeWindowButton").unbind("click");


Thickbox also has a keydown handler so that if you push ‘escape’ it closes.
Remove lines 236-245 to prevent this:
document.onkeyup = function(e){
if (e == null) { // ie
keycode = event.keyCode;
} else { // mozilla
keycode = e.which;
}
if(keycode == 27){ // close
TB_remove();
}
}


To add the ‘close’ functionality to something, do this:
$("#myTbCloseButton").click(TB_remove);

Source: (http://www.mail-archive.com/discuss@jquery.com/msg18856.html)
  • Share/Save/Bookmark
Leave a Comment :, , , , , , , , more...

What Knowledge And Software/applications Would I Need To Make My Own Web Browser?

by Beniwal on Jul.05, 2009, under Web browser

A friend of mine and I are planning on creating a web browser that will be able to be downloaded by the masses and enjoyed just like other web browsers. I just want to feel how it is like to make a web browser. If anyone has any experience can you please tell me what knowledge/skills I would need and the software/applications I would need to create a web browser. I would appreciate if you could be descriptive and explain alot to me. Wish me luck =D
  • Share/Save/Bookmark
1 Comment :, , , , , , more...

Should One Learn Plain Javascript Before Learning The Jquery Library?

by Hussain on Jul.03, 2009, under JQuery

Is it better to learn how to do things the plain javascript way before learning the jquery way?
  • Share/Save/Bookmark
2 Comments :, , , , , , , more...

What Is The Fastest Web Browser Available For Free Download?

by Hussain on Jul.03, 2009, under Web browser

I have a Slow Dial – up internet connection and I need the fastest Web browser available. I already have Firefox 3 and I find this slow. I also have Microsoft Internet Explorer 8 which I find extremely slow.
  • Share/Save/Bookmark
26 Comments :, , , , , more...

How To Fetch The Absolute Position Of Html Elements Using Jquery?

by Hussain on Jul.03, 2009, under JQuery

I have come to know that “using JavaScript frameworks like JQuery, such information (and so much more!) can be retrieved in a browser-independant fashion.” Please tell me how?
  • Share/Save/Bookmark
1 Comment :, , , , , , more...

What Is The Best Web Browser To Use Thats Fast And Secure?

by Hussain on Jul.03, 2009, under Web browser

I’ve been using Avant Browser for quite some time now, but now its just not getting it done. What do you think is the best web browser out there? What is your feeling on the opera browser? Does that get good reviews?
  • Share/Save/Bookmark
8 Comments :, , , , , more...

Web Browser?

by Hussain on Jul.03, 2009, under Web browser

How do I set up the web browser on my motorola L6?
  • Share/Save/Bookmark
1 Comment : more...

What’s New in Firefox 3.5

by narendra on Jul.03, 2009, under Web browser



Firefox 3.5  is based on the Gecko 1.9.1 rendering platform, which has been under development for the past year. Firefox 3.5 offers many changes over the previous version, supporting new web technologies, improving performance and ease of use. Some of the notable features are:

  • Available in more than 70 languages. (Get your local version!)
  • Support for the HTML5 <video> and <audio> elements including native support for Ogg Theora encoded video and Vorbis encoded audio. (Try it here!)
  • Improved tools for controlling your private data, including a Private Browsing Mode.
  • Better web application performance using the new TraceMonkey JavaScript engine.
  • The ability to share your location with websites using Location Aware Browsing. (Try it here!)
  • Support for native JSON, and web worker threads.
  • Improvements to the Gecko layout engine, including speculative parsing for faster content rendering.
  • Support for new web technologies such as: downloadable fonts, CSS media queries, new transformations and properties, JavaScript query selectors, HTML5 local storage and offline application storage, <canvas> text, ICC profiles, and SVG transforms.
Developers can find out about all the changes and new features at the Mozilla Developer Center.
  • Share/Save/Bookmark
Leave a Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Archives

All entries, chronologically...