PDA

View Full Version : can someone help me please



bogdaniel
09-24-2008, 09:49 AM
hello i'm trying to do a user system but i don't have a very good ideea what should i do from where should i start. i've started with the login form and the code for it . but on the way i've got some problems the code doesn't work :( can you help me please ?





<?php
if($logged_in == 1) {
echo 'lol';
} else {
?>
<div id="login">
<div class="content">
<form id="form1" method="POST" name="login" action="<? $_SERVER['PHP_SELF'] ?>">
<fieldset>
<legend>Sign-In</legend>
<label for="inputtext1">Client ID:</label>
<input type="text" id= "username" name="username"/>
<label for="inputtext2">Password:</label>
<input type="password" id="password" name="password" />
<input type="submit" name="login" value="Log In" />

</fieldset>
</form>
</div>
</div>
<?php
if (!isset($_SESSION['username']) || !isset($_SESSION['id'])) {
$logged_in = 0;
return;
} else {

if (!get_magic_quotes_gpc()) {

$username = mysql_real_escape_string(stripslashes($_POST['username']));
$password = mysql_real_escape_string(stripslashes(md5($_POST['password'])));
}
$sql = mysql_query("SELECT username, password FROM members WHERE username ='" .
$username . "'") or die(tmp_mysql_error());
if (mysql_numrows($sql) == 1) {
$set = mysql_fetch_array($sql);
if ($password == $set['password']) {
$_SESSION['username'] = $set['username'];
$_SESSION['id'] = $set['id'];
$_SESSION['usrlvl'] = $set['usrlvl'];
}
}
}

}
?>

Nile
09-25-2008, 01:54 AM
<form id="form1" method="POST" name="login" action="<? $_SERVER['PHP_SELF'] ?>">

Replace that with this:


<form id="form1" method="POST" name="login" action="">