Jump to content

$username variable not passed in link


Go to solution Solved by aquatradehub,

Recommended Posts

Hi, I am trying to pass a user to the page that contains any customer reviews. I am using the link 

<a href="reviews.php?username=$username">See reviews</a>

on line 26 to try and access the users review.php page, but hovering over the link or clicking on it results in the following

http://e-quatics.com/reviews.php?username=$username

this should read

eg. http://e-quatics.com/reviews.php?username=member1

Here is the code for the page. I cant seem to figure out why the $username value is not picked up by the code and used in the link.

<?php
include 'core/init.php';
include 'includes/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, 'username', 'date');
		$count_items_listed   = count_items_listed($user_id);
		$count_live_items_listed   = count_live_items_listed($user_id);
		// $count_items_sold   = count_items_sold($user_id);
		// $count_items_purchased   = count_items_purchased($user_id);
		// $count_reviews   = count_reviews($user_id);



		?>
	
		<h1><?php echo filterBadWords($profile_data['username']); ?>'s Profile</h1>
		<br>
		<p>Member Since: <?php echo $profile_data['date']; ?></p>
		<p>Number of items sold: <?php // echo $count_items_sold; ?></p>
		<p>Number of items purchased: <?php // echo $count_items_purchased; ?></p>
		<p>Number of customer reviews: <?php // echo $count_reviews ?><a href="reviews.php?username=$username">See reviews</a></p>
		<p>Number of live items currently listed: <?php echo $count_live_items_listed; ?></p>
		<p>Number of items currently listed: <?php echo $count_items_listed; ?></p>
		
		
	<?php
	} else {
		echo 'Sorry, that user doesn\'t exist!';
	}
} else {
	header('Location: index.php');
	exit();
}

include 'includes/overall/footer.php'; ?>

As always guys, your help is much appreciated.

aquaman

Link to comment
https://forums.phpfreaks.com/topic/287095-username-variable-not-passed-in-link/
Share on other sites

Because of your penchant to go into and out of PHP mode constantly, your error is because you are building that tag OUTSIDE of php mode.

 

Better script organization and techniques would alleviate the need to use <? more than once in a script.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.