where it says get user id i need it to get the value of priv from my table from the same row as the user like the get user id that finds form username to get the row the problem is wher i have writen in caps down below i want the value of priv to be the url it goes to (in priv i have the urls set up for each user)
sorry if i have worded this badly it was hard to explain
You betcha. Let's see:
* where it says get user id = so the code change is happening there?
* i need it (the script) to get the value of priv (a column name I suppose) from my table from the same row as the user like the get user id that finds form username to get the row = I need to get the value of `priv` for a certain user id/username
* the problem is = you should have put a period before this!

* where i have written in caps down below = much easier way to state this is I would like to link to the url described in `priv`
* your authentication system seems fairly weak
This seems fairly easy to do. Priv is stored in $r['priv'].
A few notes: quote your indices, so $r[userid] becomes $r['userid']. Also, make sure you used mysql_real_escape_string on $user so that you can't get an sql injection. Finally, since you expect only one row to be returned, the while loop is unnecessary. Don't interpolate ("$userid") where it's unnecesary either. New code should look like (untested):
Code: Select all
// get information on user
$mysql_user = mysql_real_escape_string($user)
$query= "SELECT `user`, `priv` FROM `$dbtable` WHERE username='$mysql_user' LIMIT 1";
$rs = mysql_query($query);
$result = mysql_fetch_array($rs);
$userid = $result['userid'];
$priv = $result['priv'];
$html_user = htmlentities($user);
setcookie('userid', $userid, time() + 3600, '/', '', 0);
echo "You have successfuly loged in! Welcome, $html_user .<br><br><a href=\"$priv\">Continue...</a>";