Jump to content

Archived

This topic is now archived and is closed to further replies.

rallokkcaz

how to show userinfo!

Recommended Posts

pleeze help i wanna show the users info on a page

pleeze help!

thank you

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
yes i do

here'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]<?php


if($_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 page
and it redirects me to the userlist

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
now it says there is an error!

here's the error

Parse error: syntax error, unexpected T_BOOLEAN_AND in /home/pokebash/public_html/profiles.php on line 3

what should i do to stop that?

Share this post


Link to post
Share on other sites
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]).

Share this post


Link to post
Share on other sites
ok i fixed one prob i had

i don't need a new query
i just want to display the user info

Share this post


Link to post
Share on other sites
ok wildteen
what does ['userdata'] do?

cause i don't know what to do with it

Share this post


Link to post
Share on other sites
Well you've setup an array ($get) with a key called userdata. its part of the get array you setup

Share this post


Link to post
Share on other sites
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]<?php

if(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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.