473,394 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.Security;

namespace Customer
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.LinkButton LinkButton1;
protected System.Web.UI.WebControls.TextBox TextBox3;
SqlConnection con;
SqlCommand cmdc,cmds;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
try
{
con=new SqlConnection("Data Source=STAR3;Database=Customer;user id=sa;password=;");
con.Open();
cmds=new SqlCommand("select * from LoginDetails",con);
con.Close();
}
catch(Exception e1)
{
Response.Write("Connection cannot be established" +e1.Message);
}
}


private void Button1_Click(object sender, System.EventArgs e)
{
if(chkpwd(TextBox1.Text,TextBox2.Text,TextBox3.Tex t))
{
FormsAuthentication.RedirectFromLoginPage(TextBox2 .Text,true);
Response.Redirect("WebForm3.aspx");
}
else
{
TextBox3.Text="";
Response.Write("User name does not exist try again");
if(System.Convert.ToInt32(ViewState["Tries"])>1)
Response.Redirect("WebForm10.aspx");
else
{
ViewState["Tries"]=System.Convert.ToInt32(ViewState["Tries"])+1;
if(System.Convert.ToInt32(ViewState["Tries"])>3)
Response.Redirect("WebForm10.aspx");
}
}
}

private void Button3_Click(object sender, System.EventArgs e)
{

}
private bool chkpwd(string cid,string uid,string pwd)
{
bool bsuccess=false;
//pwd=FormsAuthentication.HashPasswordForStoringInCo nfigFile(pwd,"sha1");
try
{
con.Open();
cmdc=new SqlCommand("select * from LoginDetails" + " where UserID = '"+uid+"'",con);
SqlDataReader drc=cmdc.ExecuteReader();
while(drc.Read())
{
if(pwd == drc["Pawd"].ToString())
{
Response.Write("Login successful");
bsuccess=true;
}

}

con.Close();
}
catch
{
bsuccess=false;
//Response.Write(Environment.NewLine+"Error:" +e1.Message+e1.HelpLink);
con.Close();
}
return bsuccess;
}
private void LinkButton1_Click(object sender, System.EventArgs e)
{
Response.Redirect("WebForm1.aspx");
}
}
}


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

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

Similar topics

1
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...
2
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...
23
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...
2
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...
0
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...
232
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...
28
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...
76
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...
0
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.