Toon posts:

[php]cookie logout probleempje

Pagina: 1
Acties:
  • 42 views sinds 30-01-2008

Verwijderd

Topicstarter
Dit is mijn code voor in/uitloggen met cookies. Het gaat fout als ik $autologin aanvink, dan logt hij neit meer uit. Als ik dat neit aan heb gevinkt logt hij wel gewoon uit.
PHP:
1
<? include('config.php');  mysql_connect("$host", "$user", "$pass"); mysql_select_db("$db");     $Query = mysql_query("SELECT * FROM members");     $Results = mysql_num_rows($Query); if($password == md5(($password))) { if($logout) {     setcookie("username", "", -1, "/");    setcookie("password", "", -1, "/");   header("Location: ./");       exit;} else {    echo "Je bent ingelogd als $username, <a href=\"login.php?logout=1\">uitloggen?</a>"; } } else {    if ($HTTP_POST_VARS["login_user"] &amp;&amp; $HTTP_POST_VARS["login_password"]) {      $pass = md5($HTTP_POST_VARS["login_password"]);       $check_pass = md5(($HTTP_POST_VARS["login_user"]));       if($pass == $check_pass) {     if($autologin) {  setcookie("username", $HTTP_POST_VARS["login_user"], time()+(30 * 24 * 3600), "/");       setcookie("password", $pass, time()+(30 * 24 * 3600), "/");      header("Location: ./");       exit;//}else {  setcookie("username", $HTTP_POST_VARS["login_user"], time()+5, "/");       setcookie("password", $pass, time()+5, "/");      header("Location: ./");       exit;      } }      else       {          echo "foute gebruikersnaam of wachtwoord."; //jammer dan :D       }    }    else    {     echo "         <html>         <head>           <title>Login</title>         </head>         <body>         <strong>Login</strong>         <form action=\"login.php\" method=\"post\">           Username:<br>           <input type=\"Text\" name=\"login_user\"><p>           Password:<br>           <input type=\"Password\" name=\"login_password\"><p>           <input class=\"text\" type=\"checkbox\" name=\"autologin\" />Log me automatisch in bij een volgend bezoek.<BR><BR>          <input type=\"Submit\" value=\"  Login!  \">         </form>         </body>         </html> ";    } } ?> ?>

Verwijderd

"mijn auto doet het niet, wat is er mis mee..."
sorry, kon het niet laten

wat heb je al geprobeerd en wat blijkt te werken en wat niet enz...

  • whoami
  • Registratie: December 2000
  • Laatst online: 20:22
Lees even de P&W Quickstart.

https://fgheysels.github.io/


  • D2k
  • Registratie: Januari 2001
  • Laatst online: 31-08 10:19

D2k

PHP:
1
<? include('config.php');  mysql_connect("$host", "$user", "$pass"); mysql_select_db("$db");     $Query = mysql_query("SELECT * FROM members");     $Results = mysql_num_rows($Query); if($password == md5(($password))) {     if($logout)     {             setcookie("username", "", -1, "/");            setcookie("password", "", -1, "/");           header("Location: ./");               exit;    }     else     {            echo "Je bent ingelogd als $username, <a href=\"login.php?logout=1\">uitloggen?</a>";     } } else {        if ($HTTP_POST_VARS["login_user"] &amp;&amp; $HTTP_POST_VARS["login_password"])     {              $pass = md5($HTTP_POST_VARS["login_password"]);               $check_pass = md5(($HTTP_POST_VARS["login_user"]));               if($pass == $check_pass)         {                 if($autologin)             {                  setcookie("username", $HTTP_POST_VARS["login_user"], time()+(30 * 24 * 3600), "/");                       setcookie("password", $pass, time()+(30 * 24 * 3600), "/");                      header("Location: ./");                       exit;                //            }            else             {                  setcookie("username", $HTTP_POST_VARS["login_user"], time()+5, "/");                        setcookie("password", $pass, time()+5, "/");                       header("Location: ./");                       exit;                   }         }              else               {                      echo "foute gebruikersnaam of wachtwoord.";             //jammer dan :D               }        }        else        {             echo "<html><head><title>Login</title></head><body><strong>Login</strong>        <form action=\"login.php\" method=\"post\">        Username:<br><input type=\"Text\" name=\"login_user\"><p>                   Password:<br><input type=\"Password\" name=\"login_password\"><p>                   <input class=\"text\" type=\"checkbox\" name=\"autologin\" />Log me automatisch in bij een volgend bezoek.<BR><BR>                  <input type=\"Submit\" value=\"  Login!  \">                 </form>                 </body>                 </html> ";        } } ?>

zie ook de P&W faq over netjes coden, Dit is veel beter te lezen

Doet iets met Cloud (MS/IBM)


Dit topic is gesloten.