Xyphon Posted December 16, 2007 Share Posted December 16, 2007 How can you check what someones user ID, and do the GET feature, then make it display certain info according to their profie. Quote Link to comment Share on other sites More sharing options...
rab Posted December 16, 2007 Share Posted December 16, 2007 Please elaborate... Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 16, 2007 Share Posted December 16, 2007 add a user login form and script <a href="whatever.php?id=<?php echo $row['id']; ?>">Member <?php echo $row['id']; ?></a> <?php $id = $_GET['id']; $results = mysql_query("select * from tblName where id='$id'"); while ($row=mysql_fetch_array($results)) { // display database contents here } ?> Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 Like In view profile Click view profile, sends you to viewprofile.php?userid=1 How do you display information acording to the user ID? Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 add a user login form and script <a href="whatever.php?id=<?php echo $_POST['id']; ?>">Member <?php echo $_POST['id']; ?></a> <?php $id = $_GET['id']; $results = mysql_query("select * from tblName where id='$id'"); while ($row=mysql_fetch_array($results)) { I get a Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/ptcrpg.awardspace.com/top.php on line 141 Error on the link. // display database contents here } ?> Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 16, 2007 Share Posted December 16, 2007 a cookie is set when you login and php checks the database and your computer for this cookie and gets your userid and it just echo/prints it from the database to the "userid" value in the url string. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 I get a Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/ptcrpg.awardspace.com/top.php on line 141 Error on the link. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 I dont understand what you're saying. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 can you explain more clearly? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 16, 2007 Share Posted December 16, 2007 there is originally a user login form a script is set-up to validate the username and password the script will check the value of the username and the password; then it will compare these values against values that are already in the database once these values are correct; a server side cookie is set by the login script so that once you come back to the forum you still will be logged in when you comeback to the forum; the forums php and mysql or sql takes the cookie and checks the database to see what the members userid is then it echos/prints our the value of the userid field to the profile link which contains the "userid" query string (ie. viewprofile.php?userid=<?php echo $row['useridfield']; ?>) Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 I know. I have all of that but the last 2. I dont understand how they take the cookie and check what the members user ID is, and also, one of my cookies IS UserID, not just username. And then I dotn get how it echos it. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 Like, i dont know how and where to do that. Quote Link to comment Share on other sites More sharing options...
fLaVV Posted December 16, 2007 Share Posted December 16, 2007 To get the cookie information (if its set) you can use $_COOKIE['name'] for example on your login page you would want it to set a cookie $username = $_POST['username']; setcookie ('username', '$username, time() + (60*60*24)); $username is what the user used in the login box. That would set a cookie. Now for finding userid. you would want to try $query = mysql_query("SELECT user_id FROM users WHERE username = '$username'"); Not sure if that is what your looking for but thats how I would do it. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 To get the cookie information (if its set) you can use $_COOKIE['name'] for example on your login page you would want it to set a cookie $username = $_POST['username']; setcookie ('username', '$username, time() + (60*60*24)); $username is what the user used in the login box. That would set a cookie. Now for finding userid. you would want to try $query = mysql_query("SELECT user_id FROM users WHERE username = '$username'"); Not sure if that is what your looking for but thats how I would do it. I already have setcookie! and Id have $query = mysql_query("SELECT user_id FROM pokemon_info"); But I just dont understand ANY of the get thing. Like 1. The link wont work if its in a PHP FILE!! 2. It doent link to the user_id 3. It deosnt display.. Look here is my top <?PHP include('Connect.php'); /* If logged out */ if (!isset($_COOKIE['UserID'])) { echo " <html> <title> Pokemon Trainer's Challenge RPG </title> <head> <style type='text/css'> A:link { color: #AFAFAF; text-decoration: underline; } A:visited { color: #AFAFAF; text-decoration: underline; } A:hover { color: #D0D0D0; text-decoration: none; } body { background-color: #000000; background-image: url('Url here if you have a background image'); scrollbar-face-color: #000000; scrollbar-highlight-color: #000000; scrollbar-shadow-color: #000000; scrollbar-darkshadow-color: #545454; scrollbar-3d-lightcolor: #545454; scrollbar-arrow-color: #ffffff; scrollbar-track-color: #545454; } .tables { border: 1px solid #252525; background-color: #313131;} .menus { width: 130px; border: 0px solid #575757; background-color: #313131;} .content { border: 0px solid #707070; background-color: #4F4F4F;} .disclaimer { border: 1px solid #252525; background-color: #313131;} </style> </head> <body> <div align='center'> <!--BANNER--> <table class='tables' cellpadding='0' cellspacing='0' width='750' height='180'> <tr><td> <center> <font face='verdana' color='#FFFFFF' size='6'><a href='index.php'> <img border='0' src='http://i3.tinypic.com/7xaet08.jpg'> </font> </tr></td> </table> <!--END of BANNER--> <!--LEFT MENU--> <table class='tables' cellpadding='4' cellspacing='0' width='750' height='250'> <tr><td class='menus' valign='top'> <font color='#AFAFAF' face='verdana' size='1'> <CENTER> <b>Main</b><br> <a href='index.php'>Home</a><br> <a href='register.php'>Register</a><br> <a href='login.php'>Log in</a><br> </CENTER> </td> <!--END of LEFT MENU--> <!--CONTENT--> <td class='content' valign='top'> <font color='#AFAFAF' face='verdana' size='1'> <div align='justify'> <br> "; } if (isset($_COOKIE['UserID'])) { echo " <html> <title> Pokemon Trainer's Challenge RPG </title> <head> <style type='text/css'> A:link { color: #AFAFAF; text-decoration: underline; } A:visited { color: #AFAFAF; text-decoration: underline; } A:hover { color: #D0D0D0; text-decoration: none; } body { background-color: #000000; background-image: url('Url here if you have a background image'); scrollbar-face-color: #000000; scrollbar-highlight-color: #000000; scrollbar-shadow-color: #000000; scrollbar-darkshadow-color: #545454; scrollbar-3d-lightcolor: #545454; scrollbar-arrow-color: #ffffff; scrollbar-track-color: #545454; } .tables { border: 1px solid #252525; background-color: #313131;} .menus { width: 130px; border: 0px solid #575757; background-color: #313131;} .content { border: 0px solid #707070; background-color: #4F4F4F;} .disclaimer { border: 1px solid #252525; background-color: #313131;} </style> </head> <body> <div align='center'> <!--BANNER--> <table class='tables' cellpadding='0' cellspacing='0' width='750' height=<tr><td>'180'> <center> <font face='verdana' color='#FFFFFF' size='6'><a href='index.php'> <img border='0' src='http://i3.tinypic.com/7xaet08.jpg'> </font> </tr></td> </table> <!--END of BANNER--> <!--LEFT MENU--> <table class='tables' cellpadding='4' cellspacing='0' width='750' height='250'> <tr><td class='menus' valign='top'> <font color='#AFAFAF' face='verdana' size='1'> <CENTER> <b>Main</b><br> <a href='index.php'>Home</a><br> <a href='logout.php'>Logout</a><br> <a href=''>Link Here</a><br><br> <b>Catergory</b><br> <a href=''>Link Here</a><br> <a href=''>Link Here</a><br> <a href=''>Link Here</a><br> <a href=''>Link Here</a><br><br> <b>Catergory</b><br> <a href=''>Link Here</a><br> <a href=''>Link Here</a><br> <a href=''>Link Here</a><br> <a href=''>Link Here</a><br> </CENTER> </td> <!--END of LEFT MENU--> <!--CONTENT--> <td class='content' valign='top'> <font color='#AFAFAF' face='verdana' size='1'> <div align='justify'> <br> "; } $ID= $_COOKIE['UserID']; $BannedResult= mysql_query("SELECT * FROM users WHERE id='$ID'"); $BannedRows= mysql_fetch_array($BannedResult); if($BannedRows['Banned']=='Yes') { echo "Sorry, you are banned. You will now be logged out, please go <a href='index.php'>back</a>."; $usercheck = addslashes($_POST['username']); $passcheck = md5(addslashes($_POST['password'])); $Result1 = mysql_query("SELECT * FROM users WHERE username='$usercheck' AND password='$passcheck'"); $Rows1 = mysql_fetch_array($Result1); $UserID = $Rows1['ID']; setcookie("UserID", "$UserID", time() - 9999999); include("bottom.php"); exit; } ?> Heres my viewparty so far <?php include('Connect.php'); include('top.php'); $userID = $_COOKIE['UserID']; $result = mysql_query("SELECT * FROM pokemon_info"); if($row = mysql_fetch_array($result)) { echo "<table border='1'>"; echo "<br /><br />"; echo "<tr>"; echo "<td><center>" . $row['pokemon_name'] . "<br /><img border='0' src='" . $row['pokemon_image'] . "'></center></td></table>"; } include('bottom.php'); ?> Can you edit those and tell me where you put stuff so I can know for future refrences? Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 Anyone? Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 Please? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.