Jump to content


Photo

how to make pages like blah?user=username


  • Please log in to reply
29 replies to this topic

#1 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 03:20 AM

i need help making them!

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 02 September 2006 - 03:26 AM

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...c,106521.0.html


Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 04:06 AM

help?

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 02 September 2006 - 04:15 AM

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.



Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 04:28 AM

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!

http://www.pokebash.com/user.php
<? 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


#6 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 04:55 AM

people?

#7 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 02 September 2006 - 04:59 AM

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)
Why doesn't anyone ever say hi, hey, or whad up world?

#8 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 05:04 AM

yes what you said and nice dude its good to start off early
i think  :D

#9 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 05:33 AM

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...

yes that is what i want to do!
can you pleeze help?

#10 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 02 September 2006 - 05:38 AM

Umm what info are you tryin to display and how is it stored in your database?
Why doesn't anyone ever say hi, hey, or whad up world?

#11 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 05:40 AM

like the username full name ect...

#12 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 05:41 AM

and i want to allow them to edit there info too

#13 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 02 September 2006 - 05:42 AM

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?
Why doesn't anyone ever say hi, hey, or whad up world?

#14 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 05:45 AM

i have a login script written and register too

they are
id
username
password
email
fullname

#15 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 05:57 AM

dude?

#16 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 02 September 2006 - 06:04 AM

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.
Why doesn't anyone ever say hi, hey, or whad up world?

#17 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 06:07 AM

thanks g' night!

#18 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 03:04 PM

lets get started again on this! ;D

#19 w32

w32
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 02 September 2006 - 03:16 PM

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

#20 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 02 September 2006 - 03:30 PM

it didn't work  :(

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users