Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data.SqlClient;
- using System.Configuration;
- using System.Data;
- namespace WebApplication1
- {
- public partial class forgot : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void resetpass_Click(object sender, EventArgs e)
- {
- SqlDataReader reader = null;
- SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
- con.Open();
- SqlCommand cmd = new SqlCommand("select * from reg where Username =@username AND Answer1 =@security1 AND Answer2 =@security2", con);
- cmd.Parameters.AddWithValue("@username", username.Text);
- cmd.Parameters.AddWithValue("@security1", sec1.Text);
- cmd.Parameters.AddWithValue("@security2", sec2.Text);
- reader = cmd.ExecuteReader();
- Label3.Text = ;
- Label4.Text = ;
- if (reader != null && reader.HasRows)
- {
- newpass.Visible = true;
- confpass.Visible = true;
- Label1.Text = "New Password";
- Label2.Text = "Confirm New Password";
- SqlConnection cons = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
- cons.Open();
- SqlCommand updates = new SqlCommand("update reg set Password='" + confpass.Text + "'", cons);
- SqlDataAdapter da = new SqlDataAdapter(updates);
- DataSet ds = new DataSet();
- da.Fill(ds);
- con.Close();
- cons.Close();
- //ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Your password has been changed')</script>");
- // Response.Redirect("Default.aspx");
- }
- else
- {
- ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('You did not meet the requirement please try again')</script>");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement