Ik ben bezig met een loginscherm (php) en heb al wat opgezocht (en wat gevonden dacht ik):
- <?
- function isLogged($LogInPage)
- {
- //Without this, PHP will create a local
- //variable called $HTTP_COOKIE_VARS.
- global $HTTP_COOKIE_VARS;
- $Host = "localhost";
- $Entered_UserName = "";
- $Entered_PassWord = "";
- if(isset($HTTP_COOKIE_VARS["UserName"]) &&
- isset($HTTP_COOKIE_VARS["PassWord"]))
- {
- $Entered_UserName = $HTTP_COOKIE_VARS["UserName"];
- $Entered_PassWord = $HTTP_COOKIE_VARS["PassWord"];
- }
- //I'm assuming that empty string user names and passwords are a no no.
- if(@mysql_connect($Host, $Entered_UserName, $Entered_PassWord) === false ||
- ($Entered_UserName == "" || $Entered_PassWord == ""))
- {
- //$LogInPage should be the name of an existing file
- //with alternative web content. If you don't wish to
- //provide such content, just pass the empty string.
- if($LogInPage != "") include($LogInPage);
- return(false);
- }
- else
- return(true);
- }
- ?>
- [list=1]
- <form name="login">
- <table align="center" cellpadding="10" cellspacing="0" border="1">
- <tr>
- <td>User Name </td>
- <td><input type="text" name="UserName" /></td>
- </tr>
- <tr>
- <td>Password</td>
- <td><input type="password" name="PassWord" /></td>
- </tr>
- <tr>
- <td colspan="2" align="right">
- <input type="button" value="log in"
- onclick="document.cookie = 'UserName=' + document.login.UserName.value;
- document.cookie = 'PassWord=' + document.login.PassWord.value;
- document.EmptyForm.submit();">
- </td>
- </tr>
- </table>
- </form>
- <form name="EmptyForm" method="post">
- </form>
- [/list]
[ Voor 13% gewijzigd door Janusch op 11-06-2006 13:46 ]