Login using the user's name as a session to be redirected to their home page

Well, I would like for my users to be logged in to index.php?id=user’s id or name. I rather use the post method so it would just be index.php. This is what I have :

There is a required (config.php) that goes here first.
mysql_connect("$host", “$username”, “$password”)or die(“cannot connect”);
mysql_select_db("$db_name")or die(“cannot select DB”);

$myusername=$_POST[‘myusername’];
$mypassword=$_POST[‘mypassword’];
// encrypt password
$encrypted_mypassword=md5($mypassword);

$sql=“SELECT * FROM $tbl_name WHERE username=’$myusername’ and password=’$encrypted_mypassword’”;
$result=mysql_query($sql);

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql=“SELECT * FROM $tbl_name WHERE username=’$myusername’ and password=’$mypassword’”;
$result=mysql_query($sql);

$count=mysql_num_rows($result);

if($count==1){

$w = mysql_query(“SELECT * FROM members WHERE id=’’ and username=’$myusername’”);

while($row = mysql_fetch_array($w))
}
if (id =“2”);
{
//redirects user to index.php?id=
echo “it worked”;
}
if (id !=2);
{
//redirecting non-member to login.php
echo “2”;
}
?>

Frist of all sorry about my english,

One problem are
if (id =“2”)
i suppossed that you want to write
if ($id ==“2”);
The same happens at id!=2, you want to write $id!=2.

but $id it’s not declared, can be declarated if you are using register_globals, or this code was included in another php file.

Sponsor our Newsletter | Privacy Policy | Terms of Service