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”;
}
?>