Torna al Thread

protected void btnRegistrati_OnClick(object sender, EventArgs e) { OdbcConnection conn = new OdbcConnection(connectionString); conn.Open(); string strsql = "SELECT * FROM users where " + "nick='" + txtFullname.Text.ToString() + "' and email='" + txtEmail.Text.ToString() + "'"; OdbcCommand objCommand = new OdbcCommand(strsql, conn); OdbcDataReader objDataReader; objDataReader = objCommand.ExecuteReader(); string fullname = "" + txtFullname.Text.ToString() + ""; string email = "" + txtEmail.Text.ToString() + ""; while (objDataReader.Read()) { if (( fullname == objDataReader["nick"].ToString()) && (email== objDataReader["email"].ToString() )) { string strSQL2 = null; string strRole = "User"; string ip = "" + Request.ServerVariables["REMOTE_ADDR"].ToString() + ""; Random rnd = new Random(); string keystring = rnd.Next(0, 99999).ToString(); string strPathPic = "http://"; string strLocks = "N"; strSQL2 = "INSERT INTO Users (nome,"; strSQL2 = strSQL2 + "cognome,"; strSQL2 = strSQL2 + "location,"; strSQL2 = strSQL2 + "birthday,"; strSQL2 = strSQL2 + "sex,"; strSQL2 = strSQL2 + "nick,"; strSQL2 = strSQL2 + "passwords,"; strSQL2 = strSQL2 + "email,"; strSQL2 = strSQL2 + "info,"; strSQL2 = strSQL2 + "url_pic,"; strSQL2 = strSQL2 + "role,"; strSQL2 = strSQL2 + "levels,"; strSQL2 = strSQL2 + "ip,"; strSQL2 = strSQL2 + "dir,"; strSQL2 = strSQL2 + "locks,"; strSQL2 = strSQL2 + "register)"; strSQL2 = strSQL2 + "VALUES('" + txtLastname.Text + "',"; strSQL2 = strSQL2 + "'" + txtFirstname.Text + "',"; strSQL2 = strSQL2 + "'" + txtCity.Text + "',"; strSQL2 = strSQL2 + "'" + txtbirthday.Text + "/" + txtbirthMonth.Text + "/" + txtbirthYear.Text + "',"; strSQL2 = strSQL2 + "'" + txtSex.Text + "',"; strSQL2 = strSQL2 + "'" + txtFullname.Text + "',"; strSQL2 = strSQL2 + "'" + txtPassword.Text + "',"; strSQL2 = strSQL2 + "'" + txtEmail.Text + "',"; strSQL2 = strSQL2 + "'" + txtInfo.Text + "',"; strSQL2 = strSQL2 + "'" + strPathPic + "',"; strSQL2 = strSQL2 + "'" + strRole + "',"; strSQL2 = strSQL2 + "1,"; strSQL2 = strSQL2 + "'" + ip + "',"; strSQL2 = strSQL2 + "'" + "/public/" + txtFirstname.Text + "-" + txtLastname.Text + "/dir/" + "',"; strSQL2 = strSQL2 + "'" + strLocks + "',"; strSQL2 = strSQL2 + "'" + DateTime.Now + "');"; OdbcCommand addUser = new OdbcCommand(strSQL2, conn); addUser.ExecuteNonQuery(); Response.Redirect("login.aspx"); } else { lblMsg.Text = "errore , user e email già esistenti"; } } conn.Close(); }
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5