Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8324301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:01:01+00:00 2026-06-09T00:01:01+00:00

I am trying to return a $user_id variable from file to if(isset(…)) statement. I

  • 0

I am trying to return a $user_id variable from file to if(isset(...)) statement. I will perform a different if statement but just trying to echo out the $user_id variable to test that I am setting the page.

<?php 
include 'core/init.php';
include 'init.image.php';
protect_page();
include 'includes/overall/overall_header.php';

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', 'username');
?>

    <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="<?php echo $profile_data['username'];?>?action=albums">Albums</a>
                </li>
                <li>
                    <a href="<?php echo $profile_data['username'];?>?action=music">Music</a>
                </li>
            </ul>
        </nav>
    </ul>
</div>

<?php
if(isset($_GET['action']) && $_GET['action']=='albums'){

$albums = get_profile_albums($user_id);

if(empty($albums)){
echo 'No Albums';
}else{

foreach($albums as $album){
if (empty($album['image'])) {
    $album['image'] = 'uploads/profile/blank_profile.gif';
}
?>
 <p><?php echo $album['name'],' (', $album['count'], ')'?> <br />
  <a href="<?php echo $profile_data['username'];?>?action=album_id=<?php echo $album['id'];?>">
    <img src="uploads/thumbs/<?php echo $album['id'];?>/<?php echo $album['image'];?>" />
  </a><br />
  <?php echo $album['description'];?>...<br />
</p>
<?php
}
}

}
if(isset($_GET['action']) && $_GET['action']=='album_id=$album['id']'){
echo $user_id;
}



if(isset($_GET['action']) && $_GET['action']=='music'){
echo'<h1>Music</h1>';
}

}else{
    echo 'Sorry, that user doesn\'t exist';
}
}else{
header('Location: index.php');
exit();
}

include 'includes/overall/overall_footer.php';
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:01:04+00:00Added an answer on June 9, 2026 at 12:01 am

    Single quotes do not parse the string but double quotes do. For example:

    $album_id = 1;
    echo 'album_id=$album_id ';
    echo "album_id=$album_id";
    

    Will result in album_id=$album_id album_id=1

    Thus, $_GET['action']=='album_id=$album_id' is checking if $_GET['action'] is equal to 'album_id=$album_id' and not what $album_id is evaluated to.

    Your check should be more along these lines:

    if (/* ... */ && $_GET['action']=="album_id=$album_id") {
    

    Edit: Suggestion.

    You should check $_GET['action'] once and store $action. From there create an if/else if/else statement checking each possible type of action (music, albums, album, etc). If a type of action requires extra user supplied data, include that in the respective if block. For example:

     $action = $_GET['action'];
     // URL: /script.php?action=albums
     if ($action == 'albums') {
         // ...
     }
     // URL: /script.php?action=album&album_id=12
     else if ($action == 'album') {
         if (!empty($_GET['album_id'])) {
              $album_id = $_GET['album_id'];
              echo "User with id $user_id is trying to access album with id $album_id";
         }
         // ...
     }
     // ...
    

    No more $_GET['action']=="album_id=$album_id"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to return the value that a $ajax call returns, from a function
I am trying to return the value by using unix_timestamp function but it behaves
I am trying to return two json sets from java which each contain key/value
I'm trying to do an if statement with data passed to the twig file
I am trying to reference a variable stored in a SESSION() from a SESSION()
I'm trying to get a local variable from a decorator. An example: def needs_privilege(privilege,
New to SPA MVC4, trying to pass a session variable to LinqToEntitiesDataController from the
I am trying to get an event calendar working from json data. I just
I am having issues trying to return the closest location to the user via
Im trying to return a SimpleQuery list that queries a single table and uses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.