Welcome Guest, Not a member yet? Register   Sign In
Session Problem

i try to do login pages with session in Codeigniter.

In order to do that , i made a model

function girisKontrol($username, $password) {
            $sha1_password = sha1($password);
            $query = "SELECT id FROM pasaj_register WHERE username = ? and password = ?";
            $result = $this->db->query($query, array($username, $sha1_password));
            if ($result->num_rows() == 1)
                return $result->row(0)->id;
                return false;

and in giris controller i made a function called giris

public function giris() {
            $userID = $this->giris->girisKontrol($username,$password);
            echo $userID;
            if (!$userID) {
                $this->session->set_flashdata('login error',TRUE);
            } else {
                        'logged_in' => TRUE,
                        'userID' => $userID));

in the same controller i made one function more:

public function main_page()
            if ($this->session->userdata('logged_in'))
                echo "Logged in";
                echo "Error";

and use all of these in view

<form method="POST" action="http://localhost:81/pasaj/giris/main_page/" name="flogin" autocomplete="off">
      <label for="username"><b>Kullanıcı adı</b> ya da <b>e-posta</b> adresiniz:</label>
      &lt;input type="text" value="" class="normalinput" name="username" id="username"&gt;
      <label for="password">Şifreniz:</label>
      &lt;input type="password" class="normalinput" value="" name="password" id="password"&gt;
      <span class="bigsubmitwbtn yellow fright"><span class="bigsubmitwbtn_left"></span>&lt;input type="submit" class="bigbutton" name="submit" value="Giriş"&gt;&lt;/span>

However as declered in main_page function , it goes directly else statement and prints Error Why ?

[eluser]Mauricio de Abreu Antunes[/eluser]
What does happen when you print $userID?

Theme © iAndrew 2016 - Forum software by © MyBB