Security Code Verification Using PHP

Security code Verification is used for security test to determine whether or not the user is human. Here is a simple security code Verification Script that Generate the code Dynamically.

<?php
$im = ImageCreate(120, 30);  //create image
$white = ImageColorAllocate($im, 255, 255, 255);  //Allocate color for  image
$black = ImageColorAllocate($im, 50, 50, 50);
$string = md5(rand(0,9999));  //Generate a random value and Calculate the md5 hash of the string
//echo $string;
$string=substr($string,1,7); //Return part of a string
$verification = $string;
ImageFill($im, 0, 0, $black); //Fill the Image
ImageString($im, 5, 30, 10, $verification, $white); //Draw the string
Imagejpeg($im, “verify.png”); //Create the Image as ‘png’ format
ImageDestroy($im);  //Destroy the image
?>
<form method=”post” action=”image_verification.php”>
<input type=’hidden’ name=’secretcode’ value=’<?=$verification?>’>
Type Code from Image:
<input type=’text’ name=’code’>
<img src=’verify.png’ border=’1′>
<input type=’submit’ name=’submit’ value=’Submit’>
</form>

<?php
if(isset($_POST['submit']))
{
$code = $_POST['code'];
$secretcode = $_POST['secretcode'];

if($code!=$secretcode){
print “<font color=’red’>Verification failed</font>”;
}
else{
print “<font color=’green’>Verification Success</font>”;
}
}
?>

Add comment October 29, 2009

Connecting MySql With Java

Download MYSQL and install it. Instructions for installing MySQL can also be found in Chapter 2 of the MySQL Manual at http://dev.mysql.com/doc/mysql/en/index.html.
To use MySQL with JDBC, you also need to install MySQL Connector/Ja JDBC driver that allows programs to access MySQL databases via JDBC. MySQL Connector/J can also be downloaded from http://www.mysql.com/products/connector/j/.
To install MySQL Connector/J:
1. Copy mysql-connector-java-5.1.7.zip to your hard disk.
2. Open mysql-connector-java-5.1.7.zip with a file extractor. Extract its      content to the C:\ drive. This will create a directory named
mysql-connector-java-5.1.7.
3. Copy the mysql-connector-java-5.1.7-bin.jar. file to the JRE’s lib\ext directory, e.g., C:\Program Files\Java\jdk1.5.0\jre\lib\ext. After doing so, you could run the application

2 comments June 9, 2009

My First WordPress Template

Today I develop a wordpress template, which is my first wordpress template. I named this template BlackWhite. You can see this template by  Clicking the screenshot below.

screenshot

Please don’t forget to comment.

2 comments November 29, 2008

Earn Money Using AlertPay.com

I am inviting you to join AlertPay.com. It’s an alternative to PayPal. There’s no harm in using two services/companies in transacting money. There are a lot of opportunities on both method that’s why I registered myself to both of them.

Advantages of AlertPay are:

1.) You can earn from referring someone to them. It’s easy to start earning. Here’s how:

Step 1: Login to your AlertPay account
Step 2: Click on the “Referral Program” Tab
Step 3: Select your personalized referral link that you can use in your emails, website, banners and so on.
Step 4: Each time someone you refer makes AlertPay their way to pay, they will pay you $5.00. When you refer more then 10 qualified friends, they will pay you $10 for each referral.
Step 5: Your referral bonus will be paid to your account 10 days after successful qualifications.

2.) There’s a new way of earning money popping out in the Internet that pays solely in AlertPay.

The later makes it more interesting to sign-in. In my next post (possibly tommorrow), I will reveal to you how to make extra dollars everyday with AlertPay.

1 comment October 20, 2008

Router Configuration in CLI mode(CISCO)

//First sub_netting the IP address & Enter into “configuration mode”:

Router >enable

Router #configure terminal

//Enter configuration commands, one per line.  End with CNTL/Z.

Router (config)#

//configure the ip address for firstEnthernet  0/0 port:

Router(config)#interface fastEthernet 0/0

Router(config-if)#ip address 172.16.1.254 255.255.255.0 //ip address and subnet mask

Router(config-if)#no shutdown

Router(config-if)#exit

//configure the ip address of the serial port 0/0/0 port:

Router(config)#interface serial 0/0/0

Router(config-if)#ip address 172.16.3.1 255.255.255.0 //ip address and subnet mask

Router(config-if)#clock rate 64000

Router(config-if)#no shutdown

//now keep the router passward protecteed:
//To change hostname

Router(config)#hostname R1-ISP

R1-ISP (config)#enable password cisco

R1-ISP (config)#line console 0

R1-ISP (config-line)#password cisco

R1-ISP (config-line)#login

R1-ISP (config-line)#exit

// now enable the Telnet service:

R1-ISP (config)#line vty 0 4

R1-ISP (config-line)#password class

R1-ISP (config-line)#login

R1-ISP (config-line)#exit

Add comment September 8, 2008

My 5th Semester Project

My Project advisor Md. Boshir Ahmed (Assistant Professor, Dept. of CSE ) advice me to develop our rental library’s website. Then I start my work and finaly I complete this project. I have developed this Site using HTML, PHP, Mysql and Java Script.

Here is the Link:
http://pollobcse05.ueuo.com/project1

Add comment July 21, 2008

Login Script

//Create Table

CREATE TABLE `login` (
`username` varchar(16) NOT NULL,
`password` varchar(100) NOT NULL,
PRIMARY KEY (`username`)
) ENGINE=MyISAM;

INSERT INTO `login` VALUES (‘alamin’, md5(‘053038′)),
INSERT INTO `login` VALUES (‘pollob’, md5(‘053031′));

//login.php
<center>
<table border=’1′>
<form method=”POST” action=”authenticate.php”>
<tr><td colspan=”2″ align=”center”>Log In</td></tr>
<tr>
<td><b>Username:</b></td>
<td><input type=”text” name=”username” size=”15″></td>
</tr>
<tr>
<td><b>Password:</b></td>
<td><input type=”password” name=”password” size=”15″></td>
</tr>
<tr>
<td colspan=”2″ align=”center”>
<input type=”submit” value=”submit” name=”submit”>
</td>
</tr>
</form>
</table>
</center>

//authenticate.php
<?php
ob_start();

mysql_connect(“localhost”, “root”) or die (“Couldn’t Connect to the server”);
mysql_select_db(“db_name”) or die (“Couldn’t Connect to database”);

// Define username and password
$username=$_POST['username'];
$password=$_POST['password'];
$crypt_pwd = md5($password);

$sql=”SELECT * FROM login WHERE username=’$username’ and password=’$crypt_pwd’”;
$result=mysql_query($sql);

$count=mysql_num_rows($result);

if($count==1){
session_register(“username”);
session_register(“password”);
$_SESSION['username'] = $username;

print “<center>”;
print “<font face=’Arial’ size=’4′ color=’red’>logged in successfully.”;
print “Redirecting ….. <META HTTP-EQUIV = ‘Refresh’ Content = ‘2; URL=sucess.php’>”;
print “</font></center>”;
}
else {
print “<center>”;
print “<font face=’Arial’ size=’4′ color=’red’>Wrong username or password, redirecting back to login page…..
<META HTTP-EQUIV = ‘Refresh’ Content = ‘2; URL =login.php’></font></center>”;
}

ob_end_flush();
?>
//sucess.php

<?php
session_start();
$get = $_SESSION['username'];
print “<center>”;
print “<font face=’Arial’ size=’4′ color=’red’>Welcome $get</font>”;
print “</center>”;
?>

Add comment May 14, 2008

Comment BOX

//Create Table

CREATE TABLE `comments` (
`id` int(11) auto_increment,
`name` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
`comment` varchar(200) NOT NULL,
`date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;

//comment.php

<?php
if(isset($_POST['posted'])){
$coment = add_to_database();
if(!$coment){
print “Eror: Databases Error”;
}
}

//show get data to browser
mysql_connect(“localhost”,”root”) or die(“Could not Connect”);
mysql_select_db(“cse_rental”) or die(“Could not Select Datadase”);

$result = mysql_query(“SELECT * FROM comments”);
$count = mysql_num_rows($result);
print “There R Currently $count Comments”;
while($q = mysql_fetch_array($result)){
?>
<style type=”text/css”>
* {
font-family:Verdana, Sans-serif;
color; #000000;
font-size: 12px
}
input,textarea{
color : #000000;
font: normal 12px;
border-collapse: collapse; border: 1px solid #000000;
}
</style>
<table width=”50%”>
<tr>
<td rowspan=’3′ valign=’top’ width=”1%”>
<?php echo $q[id]; ?>.
</td>
<td bgcolor=”#009966″>Comments:</td>
</tr>
<tr><td bgcolor=”#FFFFCC”>
<?php echo $q[comment]; ?>
</td></tr>
<tr><td bgcolor=”#CCCCCC”>This Comment is posted by <b><?php echo $q[name]; ?></b> on <?php echo $q[date]; ?></td></tr>
</table>

<?php
}
mysql_close();
?>

<!– Input from user –>
<form action=”comment.php” method=”post” enctype=”multipart/form-data”>
<input type=”hidden” name=”posted”>
<b>Add Your Comments</b><br />
Name:<br />
<input type=”text” name=”name” maxlength=”30″ size=”32″><br />
Email:<br />
<input type=”text” name=”email” maxlength=”30″ size=”32″><br />
Comments:<br />
<textarea cols=”40″ rows=”6″ name=”comment”></textarea><br />

<input type=”submit” value=”Add Comments”><input type=”reset” value=”Reset”>
</form>

<?php
//add to database
function add_to_database()
{
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$comment = trim($_POST['comment']);

mysql_connect(“localhost”,”root”) or die(“Could not Connect”);
mysql_select_db(“cse_rental”) or die(“Could not Select Datadase”);

$sql = “INSERT INTO comments (`id`,`name`,`email`,`comment`)
VALUES(”,’$name’,'$email’,'$comment’)”;
mysql_query($sql);
mysql_close();
return true;
}

?>

Add comment May 14, 2008


My Fav




My twiTTer

Error: Please make sure the Twitter account is public.

Top Clicks

 

November 2009
M T W T F S S
« Oct    
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Archives

Category Cloud

JAVA Java Script MySQL Networking(CISCO) PHP Template Uncategorized

Recent Comments

pollobcse05 on About
মাহমুদ ফয়সাল on About
pollobcse05 on Connecting MySql With Jav…
Shamim Ahmed on Connecting MySql With Jav…
Arafat Rahman on My First WordPress Templa…

Blogroll

Meta

My Flickr Photos

SDC12881

SDC12818

SDC12808

SDC12802

SDC12794

More Photos

Pages

Blogroll

Meta