943,917 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 572
  • PHP RSS
Sep 27th, 2008
0

Linking username to profile...

Expand Post »
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

PHP Syntax (Toggle Plain Text)
  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, 7 views)
File Type: php view_profile.tpl.php (1.1 KB, 5 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MiloMan is offline Offline
2 posts
since Sep 2008
Sep 27th, 2008
0

Re: Linking username to profile...

Anyone?

Please?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MiloMan is offline Offline
2 posts
since Sep 2008
Sep 27th, 2008
0

Re: Linking username to profile...

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.
Reputation Points: 358
Solved Threads: 89
Posting Shark
R0bb0b is offline Offline
986 posts
since Jun 2008
Sep 27th, 2008
0

Re: Linking username to profile...

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:

PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
heenix is offline Offline
15 posts
since Sep 2008
Sep 28th, 2008
0

Re: Linking username to profile...

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?
Reputation Points: 14
Solved Threads: 8
Junior Poster
antwan1986 is offline Offline
110 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: I have problem with two value search
Next Thread in PHP Forum Timeline: System Advice: Best Way To Approach This Problem?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC