Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. <?
  2. $action = $_GET['action'];
  3.  
  4. if (isset($_SESSION['username'])) {
  5.         print "<script>self.location.replace('?sida=inloggad');</script>";
  6. } else {
  7.  
  8. if ($action == "login") {
  9.     if (!$_POST['username']) {
  10.     print "<script>self.location.replace('?sida=login&action=error');</script>";
  11.     }
  12.     if (!$_POST['password']) {
  13.     print "<script>self.location.replace('?sida=login&action=error');</script>";
  14.     }
  15.  
  16. $query = mysql_query("SELECT * FROM flower_users WHERE username = '".$_POST['username']."' AND password = '".$_POST['password']."'");
  17.     $resultat = mysql_fetch_array($query);
  18.     if (isset($resultat['id'])) {
  19.         $_SESSION['username'] = $resultat['username'];
  20.                 print $_SESSION['username'];
  21.         print "<script>self.location.replace('?sida=inloggad');</script>";
  22.     } else {
  23.         print "<script>self.location.replace('?sida=login&action=error');</script>";
  24.     }}
  25.     mysql_close($conn);
  26. ?>
  27.  
  28. <table border="0" cellspacing="2" cellpadding="0" class="textblack">
  29.   <form method="post" action="index2.php?sida=login&action=login">
  30.   <tr>
  31.     <td>Användare:</td>
  32.     <td><input name="username" type="text" class="textblack" size="25"></td>
  33.   </tr>
  34.   <tr>
  35.     <td>Lösenord:</td>
  36.     <td><input name="password" type="password" class="textblack" size="25"></td>
  37.   </tr>
  38.   <tr>
  39.     <td>&nbsp;</td>
  40.     <td><input type="submit" class="textblack" value="Logga in"></td>
  41.   </tr>
  42.   </form>
  43. </table>
  44. <?
  45. }
  46. ?>
  47. <?
  48. if ($action == "error") {
  49.     print "<p class=\"error\">Ett problem uppstod, informationen du angav var fel!</p>";
  50. }
  51.  
  52. if ($action == "problem") {
  53.     print "<p class=\"error\">Ett problem uppstod, du måste vara inloggad för att se denna sida!</p>";
  54. }
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement