Advertisement
Guest User

Untitled

a guest
Feb 14th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data.SqlClient;
  8. using System.Configuration;
  9. using System.Data;
  10.  
  11. namespace WebApplication1
  12. {
  13. public partial class forgot : System.Web.UI.Page
  14. {
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17.  
  18. }
  19.  
  20. protected void resetpass_Click(object sender, EventArgs e)
  21. {
  22. SqlDataReader reader = null;
  23. SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
  24. con.Open();
  25. SqlCommand cmd = new SqlCommand("select * from reg where Username =@username AND Answer1 =@security1 AND Answer2 =@security2", con);
  26. cmd.Parameters.AddWithValue("@username", username.Text);
  27. cmd.Parameters.AddWithValue("@security1", sec1.Text);
  28. cmd.Parameters.AddWithValue("@security2", sec2.Text);
  29. reader = cmd.ExecuteReader();
  30. Label3.Text = ;
  31. Label4.Text = ;
  32. if (reader != null && reader.HasRows)
  33. {
  34. newpass.Visible = true;
  35. confpass.Visible = true;
  36. Label1.Text = "New Password";
  37. Label2.Text = "Confirm New Password";
  38. SqlConnection cons = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
  39. cons.Open();
  40. SqlCommand updates = new SqlCommand("update reg set Password='" + confpass.Text + "'", cons);
  41. SqlDataAdapter da = new SqlDataAdapter(updates);
  42. DataSet ds = new DataSet();
  43. da.Fill(ds);
  44. con.Close();
  45. cons.Close();
  46. //ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Your password has been changed')</script>");
  47. // Response.Redirect("Default.aspx");
  48. }
  49. else
  50. {
  51. ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('You did not meet the requirement please try again')</script>");
  52. }
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement