Jump to content

$username variable not passed in link


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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.