Advertisement
Guest User

Untitled

a guest
May 10th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. <table border=1 align="right" width=100% bgcolor="white" >
  2. <tr>
  3.     <td align="left"><font color="red" size=12><b>Glasbena trgovina</b></font></td> <!-- naslov strani -->
  4.     <td align="right">
  5.     <?php
  6.         include('mysql.php');
  7.         if(isset($_POST['submit'])){
  8.             $username = mysql_escape_string($_POST['username']);
  9.             $password = mysql_escape_string(md5($_POST['password']));  
  10.            
  11.             if(!empty($username) && !empty($password)) {
  12.                 $sql = mysql_query("SELECT * FROM users
  13.                                     WHERE username='".$username."' AND
  14.                                     user_password='".$password."' LIMIT 1");
  15.                 if(mysql_num_rows($sql)==1){
  16.                     $_SESSION['loggedin'] = true;
  17.                     $_SESSION['username'] = $username;
  18.                     echo 'Uporabnik:<font color="red"> '.$_POST['username'].' </font><a href="logout.php">  logout</a>';
  19.                 }else{
  20.                     echo 'Tvoje uporabniško ime ali geslo je napacno!';
  21.                 }
  22.                 }else{
  23.                     echo 'Vnesi uporabniško ime in geslo!';
  24.                 }
  25.         }else{
  26.             echo '<form action="index.php" method="post">
  27.             Uporabniško ime: <input type="text" name="username"/>
  28.             Geslo: <input type="password" name="password"/>
  29.             <input type="submit" name="submit" value="Vpiši se"/>
  30.             </form>';
  31.         }
  32.     //registracija link
  33.     if($_SESSION['loggedin'] == false ){
  34.         echo '<a href="register.php">Registrirajte se!</a>';
  35.     }
  36.     ?> 
  37.     </td>
  38. </tr>
  39. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement