473,671 Members | 2,252 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 1592

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

Similar topics

4
2777
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
1552
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
1430
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
1733
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
10152
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
5780
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
1508
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
2431
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
7844
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
8476
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8917
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
8821
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
8598
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
5696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4225
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...
0
4407
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2812
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

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.