daily pastebin goal
80%
SHARE
TWEET

Untitled

a guest Dec 6th, 2016 26 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Data.SqlClient;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9.  
  10. namespace Milestone_4
  11. {
  12.     public partial class login_parent : System.Web.UI.Page
  13.     {
  14.         protected void Page_Load(object sender, EventArgs e)
  15.         {
  16.  
  17.         }
  18.        
  19.         protected void Log_In_Click(object sender, EventArgs e)
  20.         {
  21.             SqlConnection con = new SqlConnection("Server=(localdb)\\MSSQLLocalDB; database= E");
  22.             SqlCommand cmd = new SqlCommand("Select * from Parents where username= @username AND Password = @password", con);
  23.             cmd.Parameters.AddWithValue("@username", TextBox1.Text);
  24.             cmd.Parameters.AddWithValue("@password", TextBox2.Text);
  25.             con.Open();
  26.             SqlDataReader dr = cmd.ExecuteReader();
  27.             bool words = false;
  28.             while (dr.Read())
  29.             {
  30.                 if (dr.HasRows == true)
  31.                 {
  32.                     Response.Write("<script>alert('login successful');</script>");
  33.                     words = true;
  34.                     break;
  35.                 }
  36.             }
  37.             if(!words) Response.Write("<script>alert('wrong username/password');</script>");
  38.         }
  39.  
  40.         protected void Back_Click(object sender, EventArgs e)
  41.         {
  42.             Response.Redirect("home.aspx");
  43.         }
  44.  
  45.     }
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top