PHP log in form
Posted: Sat Jan 03, 2004 4:24 am
Hi everyone,
I have a problem with my php. I have log-in form, like you can see,and i want that php set a cookie but in this code he doesn't set a cookie.
After the user logged in, php check if there is a cookie and if there is he goes to cp.php. My problem is that in this code he doesn't set a cookie. What's wrong with this code. Plz help me
Persone
I have a problem with my php. I have log-in form, like you can see,and i want that php set a cookie but in this code he doesn't set a cookie.
After the user logged in, php check if there is a cookie and if there is he goes to cp.php. My problem is that in this code he doesn't set a cookie. What's wrong with this code. Plz help me
Persone
Code: Select all
<?
if (isset($_POST['login'])){
if (($_POST['gebruikersnaam'] != "") && ($_POST['wachtwoord'] != "")){
require_once ("vars.php");
$Verbinding = @mysql_connect($Host, $Gebruiker, $WachtWoord) OR DIE ("Kon geen verbinding opnemen met de database!\n");
$controleren = "SELECT * FROM login WHERE gebruiker = '" . $_POST['gebruikersnaam'] . "' AND wachtwoord = '" . $_POST['wachtwoord'] . "'";
$controle = @mysql_db_query($DBNaam, $controleren, $Verbinding) OR DIE ("<b>Kon de query niet uitvoeren door volgende fout:</b><br />". mysql_errno() ." : " . mysql_error());
$bestaat_gebruiker = @mysql_num_rows($controle);
if ($bestaat_gebruiker == "1"){
$gegevens = @mysql_fetch_object($controle);
setcookie("gebruiker", $gegevens->gebruiker, time() + "31536000");
setcookie("paswoord", $gegevens->wachtwoord, time() + "31536000");
$druk_meta = "<meta http-equiv="Refresh" content="4; URL=cp.php">\n";
$druk_af = "U bent succesvol ingelogd!\n";
}else{
$druk_af = "Sorry, maar u hebt een foutieve gebruiker/paswoord ingevoerd!\n";
$druk_meta = "";
}
}else{
$druk_af = "U hebt geen gegevens ingevuld!\n";
$druk_meta = "";
}
}else{
$druk_meta = "";
$druk_af = "<form name="loginform" action="" . $_SERVER['PHP_SELF'] . "" method="post">\n";
$druk_af .= "<table border="0" cellpadding="1" cellspacing="1">\n";
$druk_af .= "<tr><td class="style7">Gebruikersnaam:</td><td><input type="text" name="gebruikersnaam" id="gebruikersnaam" maxlength="32" size="20" /></td></tr>\n";
$druk_af .= "<tr><td class="style7">Wachtwoord:</td><td><input type="password" name="wachtwoord" id="wachtwoord" maxlength="32" size="20" /></td></tr>\n";
$druk_af .= "<input type="hidden" name="login" value="login" />\n";
$druk_af .= "<tr><td colspan="2" align="middle"><input type="submit" value="login" /></td></tr>\n";
$druk_af .= "</table>\n";
$druk_af .= "</form>\n";
}
?>
<html>
<head>
<title>
:: Login ::
</title>
<style type="text/css">
.style6 {
FONT-WEIGHT: bold;
FONT-SIZE: 18px;
COLOR: #008000;
FONT-FAMILY: "Century Schoolbook";
}
BODY {
MARGIN-LEFT: 20px;
}
.style7 {
FONT-SIZE: 15px;
FONT-FAMILY: "Century Schoolbook";
}
</STYLE>
<?
echo $druk_meta;
?>
</HEAD>
<BODY>
<?
echo $druk_af;
?>
</body>
</html>