-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathRecoverPassword.aspx.cs
More file actions
81 lines (75 loc) · 2.54 KB
/
RecoverPassword.aspx.cs
File metadata and controls
81 lines (75 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
public partial class RecoverPassword : System.Web.UI.Page
{
String CS = ConfigurationManager.ConnectionStrings["MyDatabaseConnectionString1"].ConnectionString;
String GUIDvalue;
DataTable dt = new DataTable();
int Uid;
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(CS))
{
GUIDvalue = Request.QueryString["Uid"];
if (GUIDvalue != null)
{
SqlCommand cmd = new SqlCommand("select * from ForgotPassRequests where id='" + GUIDvalue + "'", con);
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
if (dt.Rows.Count != 0)
{
Uid = Convert.ToInt32(dt.Rows[0][1]);
}
else
{
lblMsg.Text = "Your Password Reset Link is Expired or Invalid !";
lblMsg.ForeColor = Color.Red;
}
}
else
{
Response.Redirect("~/Default.aspx");
}
}
if(!IsPostBack)
{
if (dt.Rows.Count != 0)
{
tbNewPass.Visible = true;
tbConfirmPass.Visible = true;
lblPassword.Visible = true;
lblRetypePass.Visible = true;
btRecPass.Visible = true;
}
else
{
lblMsg.Text = "Your Password Reset Link is Expired or Invalid !";
lblMsg.ForeColor = Color.Red;
}
}
}
protected void btRecPass_Click(object sender, EventArgs e)
{
if (tbNewPass.Text != "" && tbConfirmPass.Text != "" && tbNewPass.Text == tbConfirmPass.Text)
{
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("update users set Password='" + tbNewPass.Text + "' where Uid='" + Uid + "'", con);
con.Open();
cmd.ExecuteNonQuery();
SqlCommand cmd2 = new SqlCommand("delete from ForgotPassRequests where Uid='" + Uid + "'", con);
cmd2.ExecuteNonQuery();
Response.Redirect("~/SignIn.aspx");
}
}
}
}