Jump to content

Archived

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

rallokkcaz

how to make pages like blah?user=username

Recommended Posts

in the future, please try to search the forums for your question, before making a new post. here is a thread that addresses this very question, still on the very first page of the forum.

http://www.phpfreaks.com/forums/index.php/topic,106521.0.html

Share this post


Link to post
Share on other sites
my first guess is that your username field in your table is varchar(10) and that's why you only have 10 chars for your usernames.

as far as taking you to the login page and not the user info... you have the links pointing to users.php. is that code up there in users.php or is that in another file? because the code that displays the info is in that same code up there ^ so if you are pointing the links to somewhere else...

and actually, you don't seem to have anything even in that code above, to display the info, after it's retrieved.  so where's the part of your code where you're trying to display it?

as far as getting the login page after you click on the link: my first guess is that you have your script checking to see if the person is logged in or not, but you aren't carrying that info over to the next page.  Or rather, maybe you are trying to directly access this script for testing purposes, and you don't have any session_start() or you aren't "logged in", your "if not logged in" script is kicking you back to the login page.  but these are only guesses, as i don't have access to the rest of your code.


Share this post


Link to post
Share on other sites
ok i fixed the user character thing!!!

and i was linking to the wrong page oops

but how can i make it si when you click the links
it goes to the users info?

here's the page/code!

[url=http://www.pokebash.com/user.php]http://www.pokebash.com/user.php[/url]
[code]<? include ("header.php"); ?>

<?php
  //connect to and select db
  $conn = mysql_connect('localhost','','') or die(mysql_error());
  $db = mysql_select_db('pokebash_users',$conn) or die(mysql_error());
 
  //get a list of the info from the table to make the linkies
  $sql = "select * from maaking_users";
  $result = mysql_query($sql, $conn) or die(mysql_error());

  // for each row fetched from the results... 
  while ($list = mysql_fetch_array($result)) {
      //make the custom linkie
      echo "<a href= 'http://www.pokebash.com/user.php?id={$list['username']}'>{$list['username']}</a><br>";
  } // end while

  // if the user clicked on a linkie and therefore an id exists (the is_numeric is a basic security precaution) ...
  if (is_numeric($_GET['username'])) {
      // for easier var syntax handling
      $id = $_GET['username'];
     
      // select the video from the db based on its id     
      $sql = "select username from maaking_users where video_id = '$id'";
      $result = mysql_query($sql, $conn) or die(mysql_error());

      // if a video was found...
      $videofound = mysql_num_rows($result);
      if ($videofound) {
        $user = mysql_fetch_array($result);
        include ("header.php");
echo "<center> $id";

      } // end if found
  } // end if there was a linkie clicked
[/code]

Share this post


Link to post
Share on other sites
Umm so what exactly are you trying to accomplish?  Like where you can go to page.php?user=<user> and it displays theyre user info?  It would help if you clarified what youre trying to do...

(PS In response to your sig... I started PHP when I was about 12.5 :D)

Share this post


Link to post
Share on other sites
yes what you said and nice dude its good to start off early
i think  :D

Share this post


Link to post
Share on other sites
[quote author=corbin link=topic=106583.msg426390#msg426390 date=1157173164]
Umm so what exactly are you trying to accomplish?  Like where you can go to page.php?user=<user> and it displays theyre user info?  It would help if you clarified what youre trying to do...
[/quote]
yes that is what i want to do!
can you pleeze help?

Share this post


Link to post
Share on other sites
Umm what info are you tryin to display and how is it stored in your database?

Share this post


Link to post
Share on other sites
Do you have a login script written?  Youll need a login script to let them edit their info... And like what are the field names in the database and stuff?

Share this post


Link to post
Share on other sites
i have a login script written and register too

they are
id
username
password
email
fullname

Share this post


Link to post
Share on other sites
Sorry, got a bit distracted... Anyways I'm about to fall asleep so Im gonna head to bed... But if someone hasnt helped you tommorow I'll try :D.

Share this post


Link to post
Share on other sites
If you're trying to see user's info you'll normall have a page like this  user.php?uid=1

And then...you can get the info with something like this

<?php
//###########################################################
if($_GET['uid'])
  {
  $sql['userdata'] = mysql_query("SELECT * FROM users WHERE userid='".$_GET['uid']."' ");
    //########IF USERID EXISTS#####
    if(mysql_num_rows($sql['userdata'])>0)
      {
      $sql['userdata'] = mysql_fetch_array($sql['userdata']);
        //######GET & DISPLAY SOME USER DATA#####
        $username = $sql['userdata']['username'];
        $email = $sql['userdata']['email'];
        echo $username .'<br />'. $email;

      }
    //#####USER DOESN'T EXIST######
  else
    {
    echo 'This user is not in our database';
    }

  }
//#########REDIRECT IF UID IS NOT IN THE URL#########
else
{
  echo '<meta http-equiv="refresh" content="0;URL=any_url_you_choose" />';
}
?>

That's what I'd do to fetch user data hope it helps you

Share this post


Link to post
Share on other sites
it didn't work  :(

when you go to the page it just shows
a blank page.

Share this post


Link to post
Share on other sites
I did not write the script for you lol...it was an example for you to work upon ...I did comment it, thought you'd modify it :D

Share this post


Link to post
Share on other sites
ok i need help with this
????????????????????

:(

i can't get it to work

when i link the to the user profile
the page shows blank?
some one help
here's the page [url=http://www.pokebash.com/user.php]http://www.pokebash.com/user.php[/url]
and the code
[code]<?php
include ("config.php");
//###########################################################
if($_GET['uid'])
  {
  $sql['userdata'] = mysql_query("SELECT * FROM pokebash_users WHERE maaking_users='".$_GET['uid']."' ");
    //########IF USERID EXISTS#####
    if(mysql_num_rows($sql['userdata'])>0)
      {
      $sql['userdata'] = mysql_fetch_array($sql['userdata']);
        //######GET & DISPLAY SOME USER DATA#####
        $username = $sql['userdata']['username'];
        $email = $sql['userdata']['email'];
        echo $username .'
'. $email;

      }
    //#####USER DOESN'T EXIST######
  else
    {
    echo 'This user is not in our database';
    }

  }
//#########REDIRECT IF UID IS NOT IN THE URL#########
else
{
  echo '<meta http-equiv="refresh" content="0;URL=user.php" />';
}
?>[/code]

Share this post


Link to post
Share on other sites
questions the 'maaking_users' field contains the users id or their username??

if it does contain the userid  browsing user.php?uid=1  or any id that's actually in the dbase should bring out your user's info :)

Share this post


Link to post
Share on other sites
better yet give me allllll the fields in your database and info of what they contain, and I'll make you a working script :)

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.