Page 1 of 1

How to Make an Improved Rank Page? Help Me Out!! [SOLVED]

Posted: Sat Oct 15, 2011 12:22 am
by Gunner
I am having trouble to make a search box. See image below
Image

Do I need to put "Use Ctrl F to Search manually your targetted player"?
I think not, because some big game site like Travian already put a searchbox on their rank page. Now my question is how to limiting the rank page? So per page is player rank 1-20, and then the next page rank 21-40, and how to put a searchbox?

Thank you very much if you're willing to help.

Re: How to Make an Improved Rank Page? Help Me Out!!

Posted: Sat Oct 15, 2011 12:35 am
by Gunner
Ok now I have my next question/problem....

Why do line breaks are not visible on my profile page?
see, when I'm editing text
Image
now here is the result
Image

AND SOMETIMES IT GOES LIKE THIS
Image

PLEASE HELP ME WITH THIS CASE....
THIS IS MY PROFILE.PHP

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? include "conf/title.php"; ?></title>
<? include_once "conf/additional_header.php"; ?>
<? include_once "conf/javascript.php"; ?>
<? include_once "conf/icon.php"; ?>
<link rel="stylesheet" type="text/css" href="gpack/style.css" />
<script type="text/javascript" src="jscript/bullet.js">
</script>
</head>

<body ondragstart="return 
false" onselectstart="return false">
<?php
 session_start();
include "conf/connect.php";
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  header('Location: login.php');
  exit;
}
?><? include "conf/player_status.php"; ?>
<script type="text/javascript" language="javascript" src="jscript/wz_tooltip.js">
</script>
<div align="center">
<div id="HeaderImage"><? include "navbar.php"; ?>
</div>
<br />
<? include_once "conf/javascript_body.php"; ?>
<table width="1110" border="0">
  <tr>
    <td style="border-right: 1px dashed grey;" width="167" height="602" class="tdTop"><? include "game_sidebar.php"; ?></td>
    <td class="tdTop" width="622"><div align="center"><? include "resource.php"; ?></div><div class="Heading"><h1>Profile</h1></div><div class="Link" align="center"><a href="#">Links goes here...</a></div><br /><div align="center"><table class="gridtable" width="446" border="1">
  <tr>
    <th colspan="2">Player's Profile</th>
  </tr>
  <tr>
    <td width="222" height="358" class="tdTop"><table width="228" border="0" class="normal">
      <tr>
        <td width="76">UID:</td>
        <td width="142"><?
		if (isset($_GET['id']))
		{
		$id = $_GET['id'];
		$playerinfo="SELECT * from players where id='$id'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$uid = $playerinfo3['id'];
$name = $playerinfo3['name'];
$population = $playerinfo3['population'];
$ally = $playerinfo3['ally'];
$class = $playerinfo3['class'];
$tribe = $playerinfo3['tribes'];
echo "$uid";
		}
		else
		{
		echo "$playerid";
		}

		 ?></td>
      </tr>
      <tr>
        <td width="76">Nickname:</td>
        <td width="142"><? if (isset($_GET['id']))
		{
		echo "$name";
		 }
		 else
		 {
		 echo "$playername";
		 }
		  ?></td>
      </tr>
      <tr>
        <td width="76">Population:</td>
        <td width="142"><? if (isset($_GET['id']))
		{
		echo "$population";
		 }
		 else
		 {
		 echo "$playerpop";
		 }
		  ?></td>
      </tr>
      <tr>
        <td width="76">Alliance:</td>
        <td width="142"><?

		if (isset($_GET['id']))
		{
		 
		if ($playerinfo3['ally'] == '-')
		{
		 echo "$ally";
		 }
		 else
		 {
		 $allyinfo="SELECT * from ally where name='$ally'";
$allyinfo2=mysql_query($allyinfo) or die("could not get player stats!");
$allyinfo3=mysql_fetch_array($allyinfo2);
		 echo "<span class='Link'><a href='ally.php?$allyinfo3[id]'>$ally</a></span>";
		 }
		 }
		 else
		 {
		 echo "$playerally";
		 }
		  ?></td>
      </tr>
      <tr>
        <td width="76">Tribe</td>
        <td width="142"><? if (isset($_GET['id']))
		{
		echo "$tribe";
		 }
		 else
		 {
		 echo "$playertribes";
		 }
		  ?></td>
      </tr>
      <tr>
        <td width="76"></td>
        <td width="142"><? if (isset($_GET['id']))
		{
		echo " ";
		}
		if (isset($_GET['id']))
		{
		$id = $_GET['id'];
		if ($id == $playerid)
		{
		echo "<span class='Link'><a href='?action=edit'>» Edit Profile</a></span>";
		}
		}
		else
		{
		echo "<span class='Link'><a href='?action=edit'>» Edit Profile</a></span>";
		} ?></td>
      </tr>
      <tr>
        <td height="209" colspan="2"><hr color="#009900" noshade="noshade" />
        <?
		if (isset($_GET['action']))
		{
		$action = $_GET['action'];
		if ($action == 'edit')
		{

		$profileinfo="SELECT * from profile where pid='$playerid'";
$profileinfo2=mysql_query($profileinfo) or die("could not get player stats!");
$profileinfo3=mysql_fetch_array($profileinfo2);
		echo "<form action='?action=done' method='post'><textarea class='InputProfile' name='profileText1' cols='34' rows='13'>$profileinfo3[text1]</textarea>";
		}
		}
		 ?><?
		 if (isset($_GET['id']))
		 {
		 $pid = $_GET['id'];
		 		$profileinfo="SELECT * from profile where pid='$pid'";
$profileinfo2=mysql_query($profileinfo) or die("could not get player stats!");
$profileinfo3=mysql_fetch_array($profileinfo2);
echo "<div align='center' class='Standard'>$profileinfo3[text1]</div>";
		 }
		 else if (isset($_GET['action']))
		 {
		 $action = $_GET['action'];
		 if ($action == 'edit')
		 {
		 echo "";
		 }
		 }
		 
		 else
		 {
		 $profileinfo="SELECT * from profile where pname='$playername'";
$profileinfo2=mysql_query($profileinfo) or die("could not get player stats!");
$profileinfo3=mysql_fetch_array($profileinfo2);
echo "<div align='center' class='Standard'>$profileinfo3[text1]</div>";
		 }
		  ?>        </td>
      </tr>
    </table></td>
    <td width="208" class="tdTop"><?
		 if (isset($_GET['id']))
		 {
echo "<div align='center' class='Standard'>$profileinfo3[text2]</div>";
		 }
		 else if (isset($_GET['action']))
		 {
		 $action = $_GET['action'];
		 if ($action == 'edit')
		 {
		 echo "<textarea class='InputProfile' name='profileText2' cols='35' rows='26'>$profileinfo3[text2]</textarea>";
		 }
		 }
		 else
		 {
echo "<div align='center' class='Standard'>$profileinfo3[text2]</div>";
		 }
		  ?><?
		   if (isset($_GET['action']))
		 {
		 $action = $_GET['action'];
		 if ($action = 'edit')
		 {
		 if (isset($_POST['submit']))
		 {
		 $text1 = $_POST['profileText1'];
		 $text2 = $_POST['profileText2'];
$updateprofile1="update profile set text1='$text1' where pname='$player'";
                  mysql_query($updateprofile1) or die("Could not update player");
				  
				  $updateprofile2="update profile set text2='$text2' where pname='$player'";
                  mysql_query($updateprofile2) or die("Could not update profile");
				  
				  echo "<span class='Link'><div align='center'><a href='profile.php'>Click here to refresh, to see your updated profile</a></div></span>";
				  
		 }
		 }
		 }
		  
		   ?></td>
  </tr>
</table>
</div><?
if (isset($_GET['action']))
		{
		$action = $_GET['action'];
		if ($action == 'edit')
		{
		echo "<br /><div align='center'><input type='submit' name='submit' id='submit' class='Button' value='Save' /></div></form>";
		}
		}
 ?></td>
    <td class="tdTop" style="border-left: 1px dashed grey;" width="307"><? include "game_rightbar.php"; ?></td>
  </tr>
</table>
<? include "footer.php"; ?>
</div>
</body>
</html>

Re: How to Make an Improved Rank Page? Help Me Out!!

Posted: Fri Nov 11, 2011 1:45 pm
by Gunner
ZZZZ
can somebody help me out!!!

Re: How to Make an Improved Rank Page? Help Me Out!!

Posted: Fri Nov 11, 2011 2:26 pm
by Winawer
The textarea uses \n for new lines, not <br />. You can use nl2br when outputting the text to get the line breaks.

The update failing is probably caused by not sanitizing your inputs. See http://php.net/manual/en/function.mysql ... string.php

You can use LIMIT in MySQL to limit the amount of players on the rank page. See http://dev.mysql.com/doc/refman/5.0/en/select.html

Re: How to Make an Improved Rank Page? Help Me Out!!

Posted: Thu Nov 17, 2011 10:26 am
by Gunner
I have look the nl2br, but where do I supposed to put this?
string nl2br ( string $string [, bool $is_xhtml = true ] )
On my database? How?

Re: How to Make an Improved Rank Page? Help Me Out!!

Posted: Thu Nov 17, 2011 12:57 pm
by Chris
Somewhere in your code you have this... I don't know what line, do a search:

Code: Select all

echo "<div align='center' class='Standard'>$profileinfo3[text1]</div>"; 
This is how you want to use nl2br:

Code: Select all

echo '<div align="center" class="Standard">' . nl2br($profileinfo3['text1']) . '</div>'; 

Re: How to Make an Improved Rank Page? Help Me Out!!

Posted: Sun Nov 20, 2011 9:57 am
by Gunner
OMG thank you so much, It really works!!! :D :D

but can you tell me, why it cannot update profile? How do I fix that?
and how to make a searchbox on the rankpage? thank you...
btw, you can talk with me on Yahoo! Messenger
YM: rafli_diaz
We can talk more about this... :)

Re: How to Make an Improved Rank Page? Help Me Out!!

Posted: Sun Nov 20, 2011 1:04 pm
by dbest

Re: How to Make an Improved Rank Page? Help Me Out!!

Posted: Tue Nov 22, 2011 9:13 am
by Gunner
Hi...
I'm still confused having inputs to be sanitized. Can you help me sanitizing the input? Yes, I am pretty new in PHP. I would like to thank to all of you who have helped me out... ;)

Re: How to Make an Improved Rank Page? Help Me Out!!

Posted: Tue Nov 22, 2011 9:54 pm
by metacatdud
Here is my full-proof function that will keep you out of trouble

Code: Select all

function sanitize($var)
{
	return addslashes (htmlentities (prepreq(utf8_decode ($var)), ENT_QUOTES));
}
Now there is function there called prepreq that you will not recognize. Here it is:

Code: Select all

function prepreq($var)
{
	return isset ($_REQUEST [$var]) ? $_REQUEST [$var] : "";
}
Now that is for form, i use _REQUEST to save time on who post and who get and to avoid errors that some of those functions will output if no argument is provided.

For passed strings that you my need this (Well is paranoia but ...)

Code: Select all

function sanitizestr($var)
{
	return addslashes (htmlentities (utf8_decode($var), ENT_QUOTES));
}
Use them but google about those function to proper understand this functions