-
Notifications
You must be signed in to change notification settings - Fork 0
/
Registration.aspx.cs
45 lines (39 loc) · 1.34 KB
/
Registration.aspx.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class Registration : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnectionString1"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("INSERT INTO [Users] ([fullname], [email], [password]) VALUES (@fullname, @email, @password)", con);
cmd.Parameters.AddWithValue("fullname", TextBox1.Text.Trim());
cmd.Parameters.AddWithValue("email", TextBox2.Text.Trim());
cmd.Parameters.AddWithValue("password", TextBox3.Text.Trim());
con.Open();
int s = cmd.ExecuteNonQuery();
con.Close();
if (s == 1)
{
TextBox1.Text = string.Empty;
TextBox2.Text = string.Empty;
TextBox3.Text = string.Empty;
Literal1.Text = "Registration successfully completed!";
}
else
{
TextBox1.Text = string.Empty;
TextBox2.Text = string.Empty;
TextBox3.Text = string.Empty;
}
}
}