Jump to content

C# Kullanıcı Girişi Problemi


adam4545
 Share

Recommended Posts

Arkadaşlar c# da dosyaya daha önce yazılan ve yazım formatı kullanıcıadı#sifre seklinde olup bunu split('#') fonksiyonuyla ayırıp sonra kullanıcı girişi yapmak istiyorum kodlar aşağıda yardım edermisiniz.




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace kullanicigirisi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

FileStream fs;
StreamReader sr;


private void label2_Click(object sender, EventArgs e)
{

}

private void girisyap_buton_Click(object sender, EventArgs e)
{
// int satirSayisi = System.IO.File.ReadAllText("sifreler.txt").Split(new char[] { '\n' }).Length;
string kullanici_adi = "k_aditx";
string sifre = "k_sifretx";
fs = new FileStream(".\\sifreler.txt", FileMode.Open, FileAccess.Read);
sr = new StreamReader(fs);
string yazilar = sr.ReadToEnd();
string[] sifreler = yazilar.Split('#');
string kullanıcı_adi2 = sifreler[0];
string sifre2 = sifreler[1];


sr.Close();
fs.Close();

if (kullanici_adi==kullanıcı_adi2 && sifre==sifre2)
{
admin form = new admin();
form.Show();
this.Hide();

}

else
{
MessageBox.Show("Kullanıcı Adı veya Şifre Yanlış", "Hata!");
}
}

private void cikis_buton_Click(object sender, EventArgs e)
{
this.Close();
}
}
} Edited by adam4545
Link to comment
Share on other sites

32 kişi okumuş yok mu yardım edecek biri bu aşkşam 23:59 ödevi göndermem lazım hocaya sonra sistem dosya alımını kapatıyor
form düzenide aşağıdaki gibi
[img]http://www.tnctr.com/uploads/imgs/pre_1331666575__ef.png[/img]

Edited by adam4545
Link to comment
Share on other sites

string kullanici_adi = textBox1.Text;
string sifre = textBox2.Text;
fs = new FileStream(".\\sifreler.txt", FileMode.Open, FileAccess.Read);
sr = new StreamReader(fs);
string yazilar = sr.ReadToEnd();
string[] sifreler = yazilar.Split('#');
string kullanıcı_adi2 = sifreler[0];
string sifre2 = sifreler[1];


sr.Close();
fs.Close();

if (kullanici_adi == kullanıcı_adi2 && sifre == sifre2)
{
admin form = new admin();
form.Show();
this.Hide();

}

texboxtan aldigin verileri text dosyasi icerigiyle karsilastir eger esitse yeni pencere ac. tek degisiklik textboxtaki verileri almak gerisi dogru

Link to comment
Share on other sites

Giriş butonunun click eventine aşağıdaki kodları ekleyin.

string kullanici_adi = textBox1.Text;
string sifre = textBox2.Text;
fs = new FileStream("sifreler.txt", FileMode.Open, FileAccess.Read);
sr = new StreamReader(fs);
string yazilar = sr.ReadToEnd();
string[] sifreler = yazilar.Split('#');
string kullanıcı_adi2 = sifreler[0];
string sifre2 = sifreler[1];
sr.Close();
fs.Close();

if (kullanici_adi==kullanıcı_adi2&&sifre==sifre2)
MessageBox.Show("Hoş geldiniz");
else
MessageBox.Show("Kullanıcı adı yada şifre hatalı");

.................................................................................NOT........................................




[b]K.adi [/b]textbox'ının "name özelliği : [b]textBox1[/b] [b] [/b]

[b]şifre[/b] textbox'ının "name özelliği : [b]textBox2[/b],

[b]Giriş[/b] butonunun "name özelliği : [b]button1[/b] olmalı

Edited by artal73
Link to comment
Share on other sites

[quote name='artal73' date='13 March 2012 - 20:30 ' timestamp='1331670630' post='1169153']
Giriş butonunun click eventine aşağıdaki kodları ekleyin.

string kullanici_adi = textBox1.Text;
string sifre = textBox2.Text;
fs = new FileStream("sifreler.txt", FileMode.Open, FileAccess.Read);
sr = new StreamReader(fs);
string yazilar = sr.ReadToEnd();
string[] sifreler = yazilar.Split('#');
string kullanıcı_adi2 = sifreler[0];
string sifre2 = sifreler[1];
sr.Close();
fs.Close();

if (kullanici_adi==kullanıcı_adi2&&sifre==sifre2)
MessageBox.Show("Hoş geldiniz");
else
MessageBox.Show("Kullanıcı adı yada şifre hatalı");

.................................................................................NOT........................................




[b]K.adi [/b]textbox'ının "name özelliği : [b]textBox1[/b] [b] [/b]

[b]şifre[/b] textbox'ının "name özelliği : [b]textBox2[/b],

[b]Giriş[/b] butonunun "name özelliği : [b]button1[/b] olmalı
[/quote]


hocam ilgin için teşekkürlerde dosyadaki kayıt sisemi su şekilde
kullanıcı1#sifre1
kullanıcı2#sifre2
kullanıcı3#sifre3
kullanıcı4#sifre4
kullanıcı5#sifre5

ilk satırı okuyor onu yaptım onda sorun yok ama sanırım döngüyle satır satır okutup giriş yapmayı denemeli ve tüm satırlar bitince else kısmına gidip şifre hatalı mesajı vermesini bekliyorum ama çok denedim dongüyü nasıl nereye yazacağımı çözemedim

Edited by adam4545
Link to comment
Share on other sites

arkadaşım şu şekilde denermisin [code]using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
string parola = "deneme";
string kullanıcıadı = "mcfalsi";

if (TextBox2.Text== kullanıcıadı)
if (TextBox1.Text == parola)
{
Response.Redirect("http://www.tnctr.com");
}

else
{
Response.Write("Kullanıcı adı veya parolanız yanlış");
}

else

Response.Write("Kullanıcı adı yanlış");
}
}
[/code]

Link to comment
Share on other sites

[quote name='Mcfalsi' date='13 March 2012 - 20:56 ' timestamp='1331672207' post='1169174']
arkadaşım şu şekilde denermisin [code]using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
string parola = "deneme";
string kullanıcıadı = "mcfalsi";

if (TextBox2.Text== kullanıcıadı)
if (TextBox1.Text == parola)
{
Response.Redirect("http://www.tnctr.com");
}

else
{
Response.Write("Kullanıcı adı veya parolanız yanlış");
}

else

Response.Write("Kullanıcı adı yanlış");
}
}
[/code]
[/quote]

hocam projenin ilk örneği o şekildeydi zaten sonra dosyadan okuma şekline geçtik sonraki haftada da acces veri tabanından çekip kontrol edecek kullanıcı adı ve şifreyi

yinede eline sağlık hocam

Link to comment
Share on other sites

[code]fs = new FileStream(".\\sifreler.txt", FileMode.Open, FileAccess.Read);
// sr = new StreamReader(fs);

using (StreamReader sr = new StreamReader(fs))
{
while (sr.Peek() >= 0)
{
string yazilar = sr.ReadLine();
string[] sifreler = yazilar.Split('#');
string kullanıcı_adi2 = sifreler[0];
string sifre2 = sifreler[1];
if (kullanici_adi == kullanıcı_adi2 && sifre == sifre2)
{
admin form = new admin();
form.Show();
this.Hide();
}

}

}[/code]

satir satir boyle okutacaksin

Link to comment
Share on other sites

[quote name='cumman' date='13 March 2012 - 21:06 ' timestamp='1331672803' post='1169185']
[code]fs = new FileStream(".\\sifreler.txt", FileMode.Open, FileAccess.Read);
// sr = new StreamReader(fs);

using (StreamReader sr = new StreamReader(fs))
{
while (sr.Peek() >= 0)
{
string yazilar = sr.ReadLine();
string[] sifreler = yazilar.Split('#');
string kullanıcı_adi2 = sifreler[0];
string sifre2 = sifreler[1];
if (kullanici_adi == kullanıcı_adi2 && sifre == sifre2)
{
admin form = new admin();
form.Show();
this.Hide();
}

}

}[/code]

satir satir boyle okutacaksin
[/quote]


oldu hocam eline sağlık

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...