Jump to content

Form isn't working correctly...


zelig

Recommended Posts

I want to make it so that whoever is sending the fame (sender) doesn't send it to themselves (receiver).

 

However, I can't get it to block that. Everything else works, so something must be up with that specific requirement.

 

Any help would be appreciated!

 

Thanks!

 

<?php
//error_reporting(E_ALL);
//ini_set('display_errors', 1);
include("fightfunc.php");
include("lib.php");
define("PAGENAME", "GFame");
$player = check_user($secret_key, $db);
$x = $player->username;
if($_SESSION['234asdfas']){$y = $_SESSION['234asdfas'];}else{echo 'Error: You do not have a session variable set'; exit;}

$command = 1;


if (isset($_POST["sendfame"])) {
       
   	$maxgfame = $player->gfame;
include("tmpconfig.php");
$checkquery = mysql_query("SELECT * FROM `users` WHERE `username`='".ucwords(strtolower($_POST['receiver']))."'");
	extract($_POST);

if($sender == "")
{
    echo "You must put a sender's name in the text box.";//The amount would create a negative balance - implement error condition
}
elseif ($gfamesent == 0)
{
echo "Enter an amount greater than 0.";
}
elseif ($gfamesent < 0)
{
echo "Enter an amount greater than 0.";
}
elseif (!is_numeric($gfamesent))
{
echo "Enter a numerical amount!";
} 
elseif ($gfamesent == "")
{
echo "Enter a numerical amount!";
} 
elseif ($receiver == "")
{
echo "You must put a name in the Receiver field.";
} 
elseif ($gfamesent > $maxgfame)
{
echo "You don't have that much gfame to give.";
}
elseif ($receiver == $sender)
{
echo "You can't give gfame to yourself.";
}
elseif (mysql_num_rows($checkquery) == 0)
{
echo "That player does not exist.";
}
else
	 { 
$query = $db->execute("UPDATE `users` SET `gfame`=? WHERE `id`=?", array($player->gfame - 1, $player->id)) or die("querya failed: ". mysql_error());
if($query)
$qry = $db->execute("select * from `users` where `username`=?", array(ucwords(strtolower($_POST['reciever'])))) or die("qry failed: ".mysql_error());
$rw = $qry->fetchrow();
if($qry){
$query2 = $db->execute("UPDATE `users` SET `fame`=? WHERE `username`=?", array($rw['fame'] + 1, $rw['username'])) or die("query2 failed: ". mysql_error());
if($query2){
echo("<br><br>You have successfully transfered your gfame over.<br>");
}
        }        
    }}    
    

$player = check_user($secret_key, $db);
?>
<br /><br /><blockquote><center>GFame is fame you can award 1 other person for what you feel is "noteworthiness". In otherwords, if you feel someone is doing a superb job of role-playing their character, you can "reward" them for their actions. You may send 1 gfame point per day. And no, you cannot send it to yourself.</center></blockquote><br /><br />
<table width="100%">
<tr>
  <td colspan="2"><fieldset>
  <legend>Transfer GFame:</legend>
    You have <b><?=$player->gfame?></b> GFame to give.<br />
  <form method="post" action="gfame.php">
  <input name="sender" type="hidden" value="$player->id" id="sender" />
  <input type="submit" value="Transfer" name="sendfame">
  <input type="text" value="1" name="gfamesent"> 
    to 
  <input name="receiver" type="text" id="receiver">
  </form>
</fieldset></td>
  </tr>
</table>

Link to comment
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.