473,756 Members | 9,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

check this coding once which for displaying captcha image

15 New Member
hai,
i have written this below code for displaying captcha image whenever i entered incorrect uname,password in login page.
for that i disable the controls of captcha like textbox,labels, button and image control in source code of designing part.
and i enable those controls in an if condition which display captcha.
but if i entered correct information which is in database
it shouldn't navigate to the corresponding page
and also if entered incorrect data it shouldn't displys captcha.
whats problem behind this coding?
check it
and give correct code for this one if any.


namespace CaptchaImage
{
public partial class DefaultImage : System.Web.UI.P age
{
static int a = 0;
protected void Page_Load(objec t sender, EventArgs e)
{
if (!this.IsPostBa ck)

// Create a random code and store it in the Session object.
this.Session["CaptchaImageTe xt"] = GenerateRandomC ode();

else
{
// On a postback, check the user input.
if (this.CodeNumbe rTextBox.Text ==
this.Session["CaptchaImageTe xt"].ToString())
{
// Display an informational message.
this.MessageLab el.CssClass = "info";
this.MessageLab el.Text = "Correct!";
}
else
{
//Display an error message.
this.MessageLab el.CssClass = "error";
this.MessageLab el.Text = "ERROR: Incorrect, try again.";

// Clear the input and create a new random code.
this.CodeNumber TextBox.Text = "";
this.Session["CaptchaImageTe xt"] = GenerateRandomC ode();
}
}

}
private Random random = new Random();
private string GenerateRandomC ode()
{
string s = "";
for (int i = 0; i < 6; i++)
s = String.Concat(s , this.random.Nex t(10).ToString( ));
return s;
}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

InitializeCompo nent();
base.OnInit(e);
}

//<summary>
// Required method for Designer support - do not modify
// the contents of this method with the code editor.
// </summary>
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

protected void Button1_Click(o bject sender, EventArgs e)
{
SqlConnection con = new SqlConnection(" initial catalog=rajitha ;data source=sys01;us er id=sa");

con.Open();
// SqlDataReader dr = null;
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select Emailid,passwor d from tbl_registratio n where Emailid='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'";
cmd.CommandType = CommandType.Tex t;
SqlDataReader dr = cmd.ExecuteRead er();
// string uname = TextBox1.Text;
//string pwd = TextBox2.Text;
// if (dr.HasRows)
// {
if (dr.Read())
{
Session["Emailid"] = TextBox1.Text;
Session["password"] = TextBox2.Text;
// if (uname == dr["Emailid"].ToString() && pwd == dr["password"].ToString())
Server.Transfer ("Default2.aspx ");
return;
}
else
{
Response.Write( "you have entered incorrect user name,password") ;
// label3.Text = "you have entered incorrect username,passwo rd";
a = a + 1;
if (a > 2)
{
lb1.Enabled = true;
lb2.Enabled = true;
lb3.Enabled = true;
CodeNumberTextB ox.Enabled= true;
rfd.Enabled=tru e;
MessageLabel.En abled=true;
SubmitButton.En abled = true;
img1.Visible =true;
}
}
}
con.Close();
}
}

}
Aug 26 '08 #1
0 1596

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2792
by: Krishna Kumar | last post by:
Hai all, I am doing a project in .net and in that project I have a problem in capturing text from an image. i.e images like CAPTCHA images . which has inbuilt text with in the image.So, Can any one suggest me how to continue my work or give their valuable suggestions for capturing text in the CAPTCHA image . yours KrishnaKumar
3
1560
by: ldHH | last post by:
Hi all, Some web sites (for example mySpace) had in the registration form an image with alfanumeric chars... used to check the submit Could you say me ... how can I realize this ?? Or could you give me some link where I can read this ?? Thanks in advance. //HH
0
1437
by: want2learn | last post by:
Hi. I have this CAPTCHA image for .Net in C-Sharp and translate it into VB and as Code_Behind. http://www.mbarrick.com/blog/d6plinks/20061221-01 If i run the site/script i get the site but there is not being showing an CAPTCHA image, Why not !? http://www.kennelenggaard.dk/captcha.aspx Hope someone can help me with this.
0
1742
by: aaronwmail-usenet | last post by:
Announcing SkimpyGimpy Support for PNG image CAPTCHA generation and PNG canvases. You can now use SkimpyGimpy to generate CAPTCHA text representations as PNG image files in addition to preformatted text ASCII art, and WAVE format audio streams, either from command lines or within Python programs. Also general support for drawing text and
7
10163
by: mitchell | last post by:
hi i m using IE 6.0. i want to refresh just the captcha part when the user clicks on an image. i searched for articles on it and got a fairly good understanding of it. but i m still unable to get any results. i have used Simple AJAX Code-Kit (SACK) (http://www.twilightuniverse.com/)
4
5791
by: xeiter | last post by:
Hi, I have a captcha script on my website located at /captcha.php. What it does it generates an image with the code, displays the image (gd2) and saves the value of the code in session. How do I access that code in session from my c# windows application. I have a form in my application for registering users. The application then calls to the webserver and uses regular .php page to submit user registration. It has captcha and thats why I need...
4
1509
by: mathewgk80 | last post by:
Hi all, I displaed some random numbers in a textbox.. I am having a captcha image and i would like to display that random numbers in captcha image.. The code i used to display the random numbers in a textbox is shown below... Random r = new Random(); StringBuilder sb = new StringBuilder();
11
2436
by: Twayne | last post by:
Hi, Learning PHP code; playing with various methods of generating captcha codes: In the code below, how would I change the size of the text displayed in the captcha code? Is it even possible with this method? TIA, Twayne
10
7851
by: jeddiki | last post by:
Hi, I have a captcha script which should pick up a background image and add some random letters to it and re-display This is the part of the form that the captcha image is part of: <span >Verification Image:</span> <span ><img src="captcha.php" id="captcha" /> <a href="#renew" onclick="javascript: document.getElementById('captcha').src = 'captcha.php?' + Math.random();">refresh</a> </span>
0
10062
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9901
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9728
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8733
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7282
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3827
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2694
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.