All I am looking for is when the below code is run and the Albums or the Music links are clicked it posts to the same page, correct? hence the url changes and add the href on the end of it depending on the link clicked. Well how can I call the following when the link is clicked:
<?php echo 'Albums';?>
Original code:
if(isset($_GET['username']) === true && empty($_GET['username']) === false){
$username = $_GET['username'];
if(user_exists($username) === true){
$user_id = user_id_from_username($username);
$profile_data = user_data($user_id, 'first_name','last_name','email');
?>
<h1><?php echo $profile_data['first_name']; ?>'s Yor Page</h1>
<div id="navWrapper">
<ul>
<li>
<a href="#"><img src="uploads/profile/blank_profile.gif" width="150" height="150" id="blank_profile"></a>
</li>
<nav>
<ul>
<li>
<a href="?albums">Albums</a>
</li>
<li>
<a href="?music">Music</a>
</li>
</ul>
</nav>
</ul>
</div>
<?php
}else{
echo 'Sorry, that user doesn\'t exist';
}
}else{
header('Location: index.php');
exit();
}
include 'includes/overall/overall_footer.php';
?>
Now I have the link setup when clicked it returns yorpage.com/lr/username?albums, how can I call a php function or statement when I click on this link and go to url yorpage.com/lr/username?albums?
So a simple echo would be fine for demonstration purposes just to get a return on the click is what I am looking for. If you need more info, I don’t think you do I’m not asking to code this for me I can return the images or albums etc. I just want to find out how to handle that link being clicked and returning a simple echo when Albums or Music links are clicked. Thank You.
I’m a little lost but as I understood, your question is: How can I pass arguments in the url so that when I go to the URL http://www.example.com/username/albums it goes to albums right?
here’s an example of something similar:
Adapt this to your needs…
NOTE: Please note that I changed the argument to page instead of username so you have to update your rewrite mod rules. I also used / to separate page “arguments”. You can use “?” (i think, not sure) if you prefer…
This following a simple MVC
index.php
file pages/home.php
file pages/user.php
templates/my_template.html