473,562 Members | 3,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

this code is not validating properly pls help me to fix the error

20 New Member
hi al

i wrote a code (LOgin form) that checks the user id and if it exists validates the password but this is not all validating and simply displaying user does not exist

i am sending the code pls check and fix it pls its urgent
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using System.Data.Sql Client;
using System.Web.Secu rity;

namespace Customer
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Labe l Label1;
protected System.Web.UI.W ebControls.Labe l Label2;
protected System.Web.UI.W ebControls.Labe l Label3;
protected System.Web.UI.W ebControls.Text Box TextBox1;
protected System.Web.UI.W ebControls.Text Box TextBox2;
protected System.Web.UI.W ebControls.Butt on Button1;
protected System.Web.UI.W ebControls.Butt on Button2;
protected System.Web.UI.W ebControls.Butt on Button3;
protected System.Web.UI.W ebControls.Labe l Label4;
protected System.Web.UI.W ebControls.Link Button LinkButton1;
protected System.Web.UI.W ebControls.Text Box TextBox3;
SqlConnection con;
SqlCommand cmdc,cmds;

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
try
{
con=new SqlConnection(" Data Source=STAR3;Da tabase=Customer ;user id=sa;password= ;");
con.Open();
cmds=new SqlCommand("sel ect * from LoginDetails",c on);
con.Close();
}
catch(Exception e1)
{
Response.Write( "Connection cannot be established" +e1.Message);
}
}


private void Button1_Click(o bject sender, System.EventArg s e)
{
if(chkpwd(TextB ox1.Text,TextBo x2.Text,TextBox 3.Text))
{
FormsAuthentica tion.RedirectFr omLoginPage(Tex tBox2.Text,true );
Response.Redire ct("WebForm3.as px");
}
else
{
TextBox3.Text=" ";
Response.Write( "User name does not exist try again");
if(System.Conve rt.ToInt32(View State["Tries"])>1)
Response.Redire ct("WebForm10.a spx");
else
{
ViewState["Tries"]=System.Convert .ToInt32(ViewSt ate["Tries"])+1;
if(System.Conve rt.ToInt32(View State["Tries"])>3)
Response.Redire ct("WebForm10.a spx");
}
}
}

private void Button3_Click(o bject sender, System.EventArg s e)
{

}
private bool chkpwd(string cid,string uid,string pwd)
{
bool bsuccess=false;
//pwd=FormsAuthen tication.HashPa sswordForStorin gInConfigFile(p wd,"sha1");
try
{
con.Open();
cmdc=new SqlCommand("sel ect * from LoginDetails" + " where UserID = '"+uid+"'",con) ;
SqlDataReader drc=cmdc.Execut eReader();
while(drc.Read( ))
{
if(pwd == drc["Pawd"].ToString())
{
Response.Write( "Login successful");
bsuccess=true;
}

}

con.Close();
}
catch
{
bsuccess=false;
//Response.Write( Environment.New Line+"Error:" +e1.Message+e1. HelpLink);
con.Close();
}
return bsuccess;
}
private void LinkButton1_Cli ck(object sender, System.EventArg s e)
{
Response.Redire ct("WebForm1.as px");
}
}
}


pls be fast its urgent thanks in advance
Nov 24 '06 #1
0 2098

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

Similar topics

1
4270
by: scorpion | last post by:
I have this problem that an xml instance is validated correctly by xml tools, but not with my simple code, by setting the validating flag to true. --------------- Schema ----------------------------- <?xml version="1.0" encoding="UTF-8"?> <xs:schema elementFormDefault="qualified" xml:lang="EN"...
2
3611
by: Will | last post by:
I have been having problems validating an XForms document against the XForms schema located at http://www.w3.org/MarkUp/Forms/2002/XForms-Schema.xsd. I have reduced the XForm to its bare bones as follows: <?xml version="1.0" encoding="iso-8859-1"?> <xf:model xmlns:xf="http://www.w3.org/2002/xforms"> <xf:instance xmlns=""/> </xf:model>
23
3695
by: Hostile17 | last post by:
I keep coming across people, online and in real life, who believe that to code single tags like <br> and <img> with trailing slashes, <br /> and <img /> is considered "best practice" and when challenged, they say that "everyone's going to be using XML/XHTML soon" and say that they're "getting ready" by coding this way. Coding this way...
2
1981
by: Wally Sanford | last post by:
http://wallysanford.com is currently being redirected by Namecheap to my server at home. The link to the W3C Validator has been working fine. Suddenly, that link causes the Validator to see and properly reject the following code, apparently some redirection plumbing that's not supposed to show: 1: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML...
0
1297
by: jean-gert nesselbosch | last post by:
hello everybody, does anybody know of standardization efforts concerning the output of w3cSchema/relaxNG-validating parsers ? I use libxml2 for validation-purposes (w3c-Schema and relaxNG) and have the impression that (a) the output in case the xml-document is not valid, is not very verbose (b) the structure of the returned message (in...
232
13118
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first set of examples, after decoding the HTML FORM contents, merely verifies the text within a field to make sure it is a valid representation of an...
28
1285
by: Mike Hofer | last post by:
I've been maintaining some source code, and I've noticed some radical inconsistency in the code, particularly in the way that parameters are validated. I've noticed that this seems to have been pretty much the case throughout my career. For instance, consider the following block: If siteId <= 0 Then Throw New...
76
3035
by: Michael Stemper | last post by:
The W3C Validator is a great help, as far as it goes. However, I'm looking for something stricter. My coding style does not allow for implicit termination of an element; my intention and desire is to explicitly terminate every element. Just last night, it took me two hours to track down some funny behavior. It turned out to be caused by...
0
2881
by: kkshansid | last post by:
i cannot export my sql server database to msaccess database which i usually did successfully 3weeks ago pls help me to find the error so that i can correct it in future error is - Validating (Error) Messages * Error 0xc02020f6: Data Flow Task: Column "Project ID" cannot convert between unicode and non-unicode string data types. (SQL...
0
7576
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...
0
7867
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. ...
0
8095
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...
0
7934
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...
0
6219
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...
1
5476
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...
0
3606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2073
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
1
1187
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.