rallokkcaz Posted September 2, 2006 Share Posted September 2, 2006 pleeze help i wanna show the users info on a pagepleeze help!thank you Quote Link to comment https://forums.phpfreaks.com/topic/19520-how-to-show-userinfo/ Share on other sites More sharing options...
contrabandheart Posted September 2, 2006 Share Posted September 2, 2006 Do you store your user information in MySQL?If you want help, you should include more information about what it is you actually want to do, how the information you wish to access is stored, etc. Vague requests like "please tell me how to show a user's information" doesn't give anyone who wishes to help you any sort of starting point at all.-Cass Quote Link to comment https://forums.phpfreaks.com/topic/19520-how-to-show-userinfo/#findComment-84867 Share on other sites More sharing options...
rallokkcaz Posted September 2, 2006 Author Share Posted September 2, 2006 yes i dohere's a link to the page[url=http://www.pokebash.com/user.php]http://www.pokebash.com/user.php[/url][url=http://www.pokebash.com/profiles.php]www.pokebash.com/profiles.php[/url]here's the code for profiles.php[code]<?phpif($_GET['userid']){$id = $_GET['userid'];$get['userdata'] = mysql_query("SELECT * FROM pokebash_users WHERE userid='$id'");$get['userdata'] = mysql_fetch_array($get['userdata']);echo 'Username: ' .$get['userdata']['username'] .'';echo 'E-mail: ' .$get['userdata']['email'] .'';echo 'fullname: ' .$get['userdata']['fullname'];}else{//########REDIRECTS TO YOUR HOME PAGE IF UID IS NOT PRESENT IN THE URL#########echo '<meta http-equiv="refresh" content="0;URL=user.php" />';}?>[/code]the problem is that nothing shows up on the pageand it redirects me to the userlist Quote Link to comment https://forums.phpfreaks.com/topic/19520-how-to-show-userinfo/#findComment-84868 Share on other sites More sharing options...
wildteen88 Posted September 2, 2006 Share Posted September 2, 2006 it is becuase your are passing a id (profile.php?id=1) parameter and not a userid parameter, which is what your script is using, you want to use $_GET['id'] and not $_GET['userid'])So change this:[code]if($_GET['userid']){$id = $_GET['userid'];[/code]To this:[code]if(isset($_GET['id']) && is_numeric($_GET['id'])){ $id = $_GET['id'];[/code] Quote Link to comment https://forums.phpfreaks.com/topic/19520-how-to-show-userinfo/#findComment-84870 Share on other sites More sharing options...
rallokkcaz Posted September 2, 2006 Author Share Posted September 2, 2006 now it says there is an error!here's the errorParse error: syntax error, unexpected T_BOOLEAN_AND in /home/pokebash/public_html/profiles.php on line 3what should i do to stop that? Quote Link to comment https://forums.phpfreaks.com/topic/19520-how-to-show-userinfo/#findComment-84872 Share on other sites More sharing options...
contrabandheart Posted September 2, 2006 Share Posted September 2, 2006 Okay...We'll do this the easy way.Or the hard way, however you want to see it.What are the names of the rows within your table?Give them to me in order, and I'll write a new query that [i]should[/i] word. (Emphasis on [b]SHOULD[/b]). Quote Link to comment https://forums.phpfreaks.com/topic/19520-how-to-show-userinfo/#findComment-84874 Share on other sites More sharing options...
rallokkcaz Posted September 2, 2006 Author Share Posted September 2, 2006 ok i fixed one prob i had i don't need a new query i just want to display the user info Quote Link to comment https://forums.phpfreaks.com/topic/19520-how-to-show-userinfo/#findComment-84878 Share on other sites More sharing options...
rallokkcaz Posted September 2, 2006 Author Share Posted September 2, 2006 ok wildteen what does ['userdata'] do?cause i don't know what to do with it Quote Link to comment https://forums.phpfreaks.com/topic/19520-how-to-show-userinfo/#findComment-84882 Share on other sites More sharing options...
wildteen88 Posted September 2, 2006 Share Posted September 2, 2006 Well you've setup an array ($get) with a key called userdata. its part of the get array you setup Quote Link to comment https://forums.phpfreaks.com/topic/19520-how-to-show-userinfo/#findComment-84887 Share on other sites More sharing options...
rallokkcaz Posted September 2, 2006 Author Share Posted September 2, 2006 thank you!now is there a way to let the user edit there info? Quote Link to comment https://forums.phpfreaks.com/topic/19520-how-to-show-userinfo/#findComment-84897 Share on other sites More sharing options...
wildteen88 Posted September 2, 2006 Share Posted September 2, 2006 Create a form which submits to itself, then use PHP to populate the form fields. Have a submit button and name it update. Then have an if statement which checks whether the submit button been pressed. If has update the database.Heres an example:[code]<?phpif(isset($_GET['id']) && is_numeric($_GET['id'])){ $id = $_GET['id']; $sql = "SELECT * FROM pokebash_users WHERE userid='$id'"; $result = @mysql_query($sql) or die(mysql_error()); $user = mysql_fetch_assoc($result); echo <<<HTMLFORM<form action="{$_SERVER['PHP_SELF']}" method="post"><table border="1" cellpadding="2" cellspacing="1" width="400"> <tr> <td wdith="35%">Username:</td> <td>{$user['username']}</td> </tr> <tr> <td>Full Name:</td> <td><input type="text" name="fullname" value="{$user['fullname']}" /></td> </tr> <tr> <td>Email Address:</td> <td><input type="text" name="email" value="{$user['email']}" /></td> </tr> <tr> <td colspan="2"> <input type="hidden" name="userid" value="{$user['userid']}" /> <input type="submit" name="update" value="Update Profile"> </td> </tr></table></form>HTMLFORM;}elseif(isset($_POST['update'])){ foreach($_POST as $field_name => $field_value) { ${$field_name} = mysql_real_escape_string($field_value); } $sql = "UPDATE pokebash_users email='$email', fullname='$fullname' WHERE userid='$userid'"; $result = mysql_query($sql) or die(mysql_error()); echo "Successfully updated profile";}else{ //########REDIRECTS TO YOUR HOME PAGE IF UID IS NOT PRESENT IN THE URL######### echo '<meta http-equiv="refresh" content="0;URL=user.php" />';}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/19520-how-to-show-userinfo/#findComment-84901 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.