Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

PHP login wont work

Codes here !

Moderators: macek, egami, gesf

PHP login wont work

Postby ristic » Wed Jun 26, 2013 8:48 am

Hi, i've got a problem which i cant find a way around it, tho i think everything is OK with my php code, so i need an opinion if anyone can spot something...

Anyway, this is my php code:
Code: Select all
<?php session_start(); ?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Logovanje</title>
    </head>
    <body>
        <?php
        if (isset($_POST['prijaviSe']))
        {
            include('otvori_konekciju.php');
            $korisnickoIme = $_POST['korisnickoIme'];
            $lozinka = md5($_POST['lozinka']);
            $rezultat = mysql_query("SELECT * FROM korisnik WHERE korisnicko_ime = '$korisnickoIme' AND lozinka = '$lozinka'");
            include('zatvori_konekciju.php');
            if ($rezultat && mysql_num_rows($rezultat) > 0)
            {
                $red = mysql_fetch_assoc($rezultat);
                $_SESSION['id'] = $red['id'];
                $_SESSION['korisnickoIme'] = $red['korisnicko_ime'];
                header('Location: index.php');
            }
            else
            {
                echo '<span style="color: red;">Korisnicko ime ili lozinka nisu ispravni.</span><hr />';
            }
        }
        ?>
        <form action="logovanje.php" method="POST">
            <table>
                <tr>
                    <td>Korisnicko ime:</td>
                    <td><input type="text" name="korisnickoIme" /></td>
                </tr>
                <tr>
                    <td>Lozinka:</td>
                    <td><input type="password" name="lozinka" /></td>
                </tr>
            </table>
            <hr />
            <input type="submit" value="Prijavi se" name="prijaviSe" />
        </form>
    </body>
</html>


and my table with 2 usernames, admin and test, with their password in next column

Image

as u can see, in my php code, my entered password is hashed and then compared with password in the table...but when i type in my login window : "test" , "test"; it prints me out the error message...that's why i changed admins pass to 'admin' (before it was some random hash code like the password for test) and it's still not working...i really don't know what's the problem, and because of that i cant continue my work....Can anyone help? Thank you.
ristic
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Jun 26, 2013 8:42 am

Re: PHP login wont work

Postby yasminlove1 » Wed Jun 26, 2013 9:47 am

i think that the ?> not after session_start(); must..?
yasminlove1
New php-forum User
New php-forum User
 
Posts: 3
Joined: Wed Jun 26, 2013 9:18 am

Re: PHP login wont work

Postby ristic » Wed Jun 26, 2013 1:47 pm

i don't understand u?
ristic
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Jun 26, 2013 8:42 am


Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.