PDA

View Full Version : Membership System Problem.



lMattz
06-04-2006, 08:07 AM
As you may or may not of seen. This tutorial from techtuts was posted:

http://www.habboxforum.com/showthread.php?t=123065&highlight=Advanced+User+System

I managed to follow the tutorial and complete everything that is said to do. The problem is if i enable someone to register then login it says sorry your user level is no 5. So basically only admins can use it. If anyone knows how i could sort this please reply or pm.

Cheers.

- Matt

Jamie.
06-04-2006, 08:48 AM
I'll look it up, if you wish i can send you a already made one which you just connect to db and it will work :s

lMattz
06-04-2006, 08:49 AM
Hey, thanks for the offer but i have loads of mods on the current one which i need to keep. Im not sure what has gone wrong because last time i put it all together as a staff area it worked briliantly.

Thanks

- Matt

Jamie.
06-04-2006, 08:51 AM
may u post the login script like all of the login.php script

lMattz
06-04-2006, 08:54 AM
Its the same as the one in the topic:


<?
oB_start();
// allows you to use cookies.
include("config.php");
if (!$logged[username])
{
if (!$_POST[login])
{
echo("
<center><form method=\"POST\">
<table>
<tr>
<td align=\"right\">
Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\">
</td>
</tr>
<tr>
<td align=\"right\">
Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\">
</td></tr><tr>
<td align=\"center\">
<input type=\"submit\" name=\"login\" value=\"Login\">
</td></tr><tr>
<td align=\"center\">
<a href=\"register.php\">Register Here</a>
</td></tr></table></form></center>");
}
if ($_POST[login]) {
// the form has been submitted. We continue...
$username=$_POST['username'];
$password = md5($_POST[password]);
// the above lines set variables with the submitted information.
$info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($info);
if($data[password] != $password) {
// the password was not the user's password!
echo "Incorrect username or password!";
}else{
// the password was right!
$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$user = mysql_fetch_array($query);
// gets the user's information
setcookie("id", $user[id],time()+(60*60*24*5), "/", "");
setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
// the above lines set 2 cookies. 1 with the user's id and another with his/her password.
echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://yoursite.com\"/>Thank You! You will be redirected");
// modify the above line...add in your site url instead of yoursite.com
}
}
}
else
{
// we now display the user controls.
echo ("<center>Welcome <b>$logged[username]</b><br /></center>
- <a href=\"editprofile.php\">Edit Profile</a><br />
- <a href=\"members.php\">Member List</a><br />
- <a href=\"logout.php\">Logout</a>");
}
?>

Jamie.
06-04-2006, 08:56 AM
<?
oB_start();
// allows you to use cookies.
include("config.php");
if (!$logged[username])
{
if (!$_POST[login])
{
echo("
<center><form method=\"POST\">
<table>
<tr>
<td align=\"right\">
Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\">
</td>
</tr>
<tr>
<td align=\"right\">
Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\">
</td></tr><tr>
<td align=\"center\">
<input type=\"submit\" name=\"login\" value=\"Login\">
</td></tr><tr>
<td align=\"center\">
<a href=\"register.php\">Register Here</a>
</td></tr></table></form></center>");
}
if ($_POST[login]) {
// the form has been submitted. We continue...
$username=$_POST['username'];
$password = md5($_POST[password]);
// the above lines set variables with the submitted information.
$info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($info);
if($data[password] != $password) {
// the password was not the user's password!
echo "Incorrect username or password!";
}else{
// the password was right!
$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$user = mysql_fetch_array($query);
// gets the user's information
setcookie("id", $user[id],time()+(60*60*24*5), "/", "");
setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
// the above lines set 2 cookies. 1 with the user's id and another with his/her password.
echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://PUT YOUR SITE URL IN HERE\"/>Thank You! You will be redirected");
// modify the above line...add in your site url instead of yoursite.com
}
}
}
else
{
// we now display the user controls.
echo ("<center>Welcome <b>$logged[username]</b><br /></center>
- <a href=\"editprofile.php\">Edit Profile</a><br />
- <a href=\"members.php\">Member List</a><br />
- <a href=\"logout.php\">Logout</a>");
}
?>

I dont see anything wrong with that :s
May i ask what page you are having these problems?

lMattz
06-04-2006, 09:00 AM
Its that page because when someone with a user level of 1 logs in. It just doesnt let them proceed on :'(

- Matt

Jamie.
06-04-2006, 09:03 AM
Right, i will look at my code a min n compare it with yours,


<?
oB_start();
// allows you to use cookies.
include("config.php");
if (!$logged[username])
{
if (!$_POST[login])
{
echo("
<center><form method=\"POST\">
<table>
<tr>
<td align=\"right\">
Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\">
</td>
</tr>
<tr>
<td align=\"right\">
Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\">
</td></tr><tr>
<td align=\"center\">
<input type=\"submit\" name=\"login\" value=\"Login\">
</td></tr><tr>
<td align=\"center\">
<a href=\"register.php\">Register Here</a>
</td></tr></table></form></center>");
}
if ($_POST[login]) {
// the form has been submitted. We continue...
$username=$_POST['username'];
$password = md5($_POST[password]);
// the above lines set variables with the submitted information.
$info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($info);
if($data[password] != $password) {
// the password was not the user's password!
echo "Incorrect username or password!";
}else{
// the password was right!
$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$user = mysql_fetch_array($query);
// gets the user's information
setcookie("id", $user[id],time()+(60*60*24*5), "/", "");
setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
// the above lines set 2 cookies. 1 with the user's id and another with his/her password.
echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://yoursite.com\"/>Thank You! You will be redirected");
// modify the above line...add in your site url instead of yoursite.com
}
}
}
else
{
// we now display the user controls.
$new = mysql_query("select * from pmessages where unread = 'unread' and touser = '$logged[username]'");
$new = mysql_num_rows($new);
echo ("<center>Welcome <b>$logged[username]</b><br /></center>
- <a href=\"editprofile.php\">Edit Profile</a><br />
- <a href=\"members.php\">Member List</a><br />
- <a href=\"messages.php\">Private Message Center ($new new)</a><br />
- <a href=\"logout.php\">Logout</a>");
}
?>
^^ Thats my code

Edit: try that it looks as if your missing some code

lMattz
06-04-2006, 09:04 AM
Okay, thankyou.

- Matt

Jamie.
06-04-2006, 09:05 AM
Tell me if it works. :)

lMattz
06-04-2006, 09:09 AM
Its working :O! Omgawwwwwd :D. Cheers Blondie. :D +Rep

- Matt

ADAM:
06-04-2006, 09:09 AM
Hey
Might be because you missed this bit


echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://PUT YOUR SITE URL IN HERE\"/>Thank You! You will be redirected");

Jamie.
06-04-2006, 09:10 AM
Yeh i tried making that obvious glad to help :D

lMattz
06-04-2006, 09:19 AM
Put my site link in the slot and it says:

Parse error: parse error, unexpected '<' in URL HERE on line 46

Jamie.
06-04-2006, 09:19 AM
ok ill try sort tht

wots ure site?

ADAM:
06-04-2006, 09:25 AM
This is what mine looks like:

URL=http://www.ads.harkonnenhosting.co.uk/test/timetable/login.php\"/>Thank You! You will be redirected");


Edit: You have got to make sure you put in the login.php url

Jamie.
06-04-2006, 09:46 AM
This is what mine looks like:

URL=http://www.ads.harkonnenhosting.co.uk/test/timetable/login.php\"/>Thank You! You will be redirected");


Edit: You have got to make sure you put in the login.php url

yeh :D

ADAM:
06-04-2006, 09:47 AM
Tell me when you get it working, i wanna know what was wrong with it.

Jamie.
06-04-2006, 09:48 AM
yep im in suspense!

Want to hide these adverts? Register an account for free!