if (con.State == ConnectionState.Open)
con.Close();
con.Open();
SqlCommand c = new SqlCommand("select word,category from unwanted", con);
//SqlCommand c = new SqlCommand("select word,category from unwanted where word ='"+txtWhatsOnYourHeart.Text+"' ", con);
SqlDataReader r = c.ExecuteReader();
// if (r.Read())
while(r.Read())
{
al.Add(r[0].ToString());
//a = r[0].ToString();
b = r[1].ToString();
}
a = txtWhatsOnYourHeart.Text;
int cnt=0;
foreach(string i in al)
{
if(txtWhatsOnYourHeart.Text.Contains(i))
{
cnt++;
//a = int.Parse(cnt.ToString());
}
}
if(cnt==0)
{
if (con.State == ConnectionState.Open)
con.Close();
string PostDate = DateTime.Now.ToLongDateString();
con.Open();
string InsertPostquery = "Insert into posts (Post,FromId,ToId,PostDate)values('" + txtWhatsOnYourHeart.Text + "','" + Session["name"].ToString() + "','" + Convert.ToInt32(Session["CurrentProfileId"]) + "','" + PostDate + "')";
cmd = new SqlCommand(InsertPostquery, con);
cmd.ExecuteNonQuery();
//Database.InsertData(InsertPostquery);
LatestUpdates();
txtWhatsOnYourHeart.Text = string.Empty;
Response.Write("<script>alert('Message posted successfully' )</script>");
con.Close();
// Response.Write("ddddd");
}
else
{
if (con.State == ConnectionState.Open)
con.Close();
con.Open();
SqlCommand h = new SqlCommand("insert into message values('" + Session["name"].ToString() + "','" + a + "','" + b + "')", con);
h.ExecuteNonQuery();
Response.Write("<script>alert('Blocked post')</script>");
con.Close();
con.Open();
cmd = new SqlCommand("select name, emailid from register where name='" + Session["name"].ToString() + "'", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
Session["id"] = dr[1].ToString();
Session["name"] = dr[0].ToString();
}
String m = Session["id"].ToString();
String n = Session["name"].ToString();
sendmail(a, n, b, m);
con.Close();
//Response.Write("aaaa");
}
con.Close();
settu
0
Newbie Poster
Sulaiman_1
-2
Light Poster
Sulaiman_1
-2
Light Poster
ameerbatcha
0
Newbie Poster
ameerbatcha
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.