Jump to content

Recommended Posts

Basically for a game im making theres a home page which shows the players name... The name is a link to the players profile.php page.

 

ive given it a try here but cant seem to get it working.

 

<td width="90" bgcolor="#000000" class="style5"><strong>Name</strong></td>
    <td width="10" bgcolor="#000000" class="style5"> </td>
    <td width="176" bgcolor="#000000" class="style5"><a href=\"profile.php?id=" . $member['username'] .class="style7"><?=$player->username?>
    </a></td>

 

profile.php?id=admin is the link to "my" players profile... but it for other it will still only link to my profile.

Link to comment
https://forums.phpfreaks.com/topic/127297-making-a-link-work/
Share on other sites

<?php
include("lib.php");
define("PAGENAME", "Profile");
$player = check_user($secret_key, $db);

//Check for user ID
if (!$_GET['id'])
{
header("Location: members.php");
}
else
{
$query = $db->execute("select `id`, `username`, `registered`, `level`, `kills`, `deaths`, `hp` from `players` where `username`=?", array($_GET['id']));
if ($query->recordcount() == 0)
{
	header("Location: members.php");
}
else
{
	$profile = $query->fetchrow();
}
}

include("templates/private_header.php");
?>


<fieldset>
<legend><?=$profile['username']?>'s Profile</legend>
<table width="90%">
<tr>
<td width="50%">Username:</td>
<td width="50%"><?=$profile['username']?> (<a href="mail.php?act=compose&to=<?=$profile['username']?>">Mail</a>)</td>
</tr>
<?=$profile['style']?>
<tr>
<td>Level:</td>
<td><?=$profile['level']?></td>
</tr>
<tr><td></td></tr>
<tr>
<td>Status:</td>
<td><font color="<?=($profile['hp']==0)?"red\">Dead":"green\">Alive"?></font></td>
</tr>
<tr>
<td>Kills:</td>
<td><?=$profile['kills']?></td>
</tr>
<tr>
<td>Deaths:</td>
<td><?=$profile['deaths']?></td>
</tr>
<tr><td></td></tr>
<tr>
<td>Registered:</td>
<td><?=date("F j, Y, g:i a", $profile['registered'])?></td>
</tr>
<tr>
<td>In-Game Age:</td>
<?php
$diff = time() - $profile['registered'];
$age = intval(($diff / 3600) / 24);
?>
<td><?=$age?> days</td>
</tr>
<tr>
<td>Gender:</td>
<td><?=$profile['gender']?></td>
</tr>
</table>
<br /><br />
<center>
<a href="battle.php?act=attack&username=<?=$profile['username']?>">Battle</a>
<a href="mugging.php?act=mugging&username=<?=$profile['username']?>">Mug</a>
</center>

</fieldset>


<?php
include("templates/private_footer.php");
?>

Link to comment
https://forums.phpfreaks.com/topic/127297-making-a-link-work/#findComment-658383
Share on other sites

It looks like in your first post you are mixing some php in with html.  You have some quotes escaped, but its within regular html (from what you've posted anyway).

 

Try:

<td width="176" bgcolor="#000000" class="style5"><a href="profile.php?id="<?php echo $member['username']; ?>" class="style7"><?=$player->username?>
    </a></td>

 

 

Link to comment
https://forums.phpfreaks.com/topic/127297-making-a-link-work/#findComment-658446
Share on other sites

Not all servers have short tags enabled, so it won't work on all servers, but <?php works everywhere. 

 

Ah, I left one of your original quotes in after profile.php?id=, try:

<a href="profile.php?id=<?php echo $member['username']; ?>" class="style7"><?=$player->username?>
    </a>

 

Link to comment
https://forums.phpfreaks.com/topic/127297-making-a-link-work/#findComment-658470
Share on other sites

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.