Linking username to profile...

Reply

Join Date: Sep 2008
Posts: 2
Reputation: MiloMan is an unknown quantity at this point 
Solved Threads: 0
MiloMan MiloMan is offline Offline
Newbie Poster

Linking username to profile...

 
0
  #1
Sep 27th, 2008
Posting this for a friend here is his question...

Thanks in Advance.


hey, this is my first post on these forums, i have just started learning php after doing no coding whatsoever for a while. i have to successfully get past this first, so here goes.

i have a site, where you login in, and then i want to show stats (name, favourite football club, games played, goals scored etc)

i have this file called view_profile.php that then links to view_profile.tpl.php.

the error im getting is 'There was no username entered in the URL.'

I think all that need to happen is for it to get the right username that your logged in under, but this is not showing it, can someone tell me what is missing?

Also, if you fancy helping to complete this website, and play fifa 08/09, please give me a shout

  1. <?php
  2.  
  3. require "global.php";
  4. $body = new template(TPL_ROOT);
  5. check_login();
  6.  
  7. if(!$_GET['get_username'])
  8. {
  9. full_error("Error", "There was no username entered in the URL.");
  10. exit;
  11. }
  12. $get_username = secure_input($_GET['get_username']);
  13. $get_username = str_replace("_", " ", $get_username);
  14. $user_query = $mysql->query("SELECT username, user_level, real_name, favourite_clubs, age, short_bio, nationality, second_nationality, positions, register_timestamp, lastlogin_timestamp FROM users WHERE username='".$get_username."'");
  15. if($mysql->num_rows($user_query) < 1)
  16. {
  17. full_error("Error", "There is no user with the name of, <strong>".$get_username."</strong>.");
  18. exit;
  19. }
  20. $user_results = $mysql->fetch_array($user_query);
  21. $title = $user_results['username'];
  22.  
  23. $body->set('user_results', $user_results);
  24.  
  25. $tpl->set('title', $title);
  26. $body->set('error', null);
  27. $tpl->set('body', $body->fetch("view_profile.tpl.php"));
  28.  
  29. echo $tpl->fetch('template.tpl.php');
  30.  
  31. $mysql->close();
  32.  
  33. ?>
Attached Files
File Type: php view_profile.php (973 Bytes, 2 views)
File Type: php view_profile.tpl.php (1.1 KB, 1 views)
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 2
Reputation: MiloMan is an unknown quantity at this point 
Solved Threads: 0
MiloMan MiloMan is offline Offline
Newbie Poster

Re: Linking username to profile...

 
0
  #2
Sep 27th, 2008
Anyone?

Please?
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: Linking username to profile...

 
0
  #3
Sep 27th, 2008
copy the url from the address bar and post it and I'll tell you what is wrong.
Last edited by R0bb0b; Sep 27th, 2008 at 4:20 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 15
Reputation: heenix is an unknown quantity at this point 
Solved Threads: 1
heenix heenix is offline Offline
Newbie Poster

Re: Linking username to profile...

 
0
  #4
Sep 27th, 2008
Hi there,

I believe the problem here is this may not be entirely your system (correct me if i'm wrong here). If you've just started coding PHP, as you've stated, I doubt you'll have reached templating or advanced security coding like this.

However, the problem lies in the following statement:

  1. if(!$_GET['get_username'])
  2. {
  3. full_error("Error", "There was no username entered in the URL.");
  4. exit;
  5. }

The page is expecting a GET parameter named "get_username", which means your url should look like this:

view_profile.php?get_username=heenix

As a side note, .tpl.php or .tpl files are usually Smarty Template files so I'm not sure as to why you would want to link to them?

Christopher Lord.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 110
Reputation: antwan1986 is an unknown quantity at this point 
Solved Threads: 8
antwan1986's Avatar
antwan1986 antwan1986 is offline Offline
Junior Poster

Re: Linking username to profile...

 
0
  #5
Sep 28th, 2008
The above posters are correct, it's looking for a variable passed to it through the address bar. If this is user data make sure you that the function "secure_input()" is properly sanitizing the information. What php functions is this function using?
"Beneath this mask there is more than flesh. Beneath this mask there is an idea, Mr. Creedy, and ideas are bulletproof." - V
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC