Jump to content


Photo

Post vars + adding points


  • Please log in to reply
2 replies to this topic

#1 Ph0enix

Ph0enix
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 10 May 2006 - 09:02 PM

Ok i have to problems and i would really appreciate any help with these.

1) I'm making a gaming league and i would like people to report games when they have won.
I know how to make a HTML form but then when i send the info to a php script how do i turn the information into variables so i can use then further down in the script.

2) My second problem is that when people report a game i would like 5 points to be added to the points but i cant do it. I dont get an error but the script just doesnt work.. This is my script.


$name = "Ph0enix";
$db = mysql_connect("HOST", "USERNAME" , "PASSWORD");
mysql_select_db('DBNAME');
mysql_query("UPDATE points SET points = points + 5 WHERE user_name= $name");


Can anyone please tell me what im doing wrong and help me!

Thanks!
[url=http://www.slimphoenix.com][/url]

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 10 May 2006 - 09:36 PM

1: You can use $_POST for this
if(isset($_POST['submit']))
{
$field_1 = htmlspecialchars($_POST['field_1']);

}
else
{
echo <<<__HTML_END
<form action="page.php" method="post">
Field 1: <input type="text" name="field_1" value="" size="30" />
<input type="submit" name="submit" value="Submit Form" />
</form>
__HTML_END;
}

2: add single quotes around $user,
mysql_query("UPDATE points SET points = points + 5 WHERE user_name= [!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]'[!--colorc--][/span][!--/colorc--]$name[!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]'[!--colorc--][/span][!--/colorc--]") or die(mysql_error());

#3 Ph0enix

Ph0enix
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 10 May 2006 - 09:55 PM

YYYEEEAAAHHH!!! It works! Thanks a lot mate you helped loads!
[url=http://www.slimphoenix.com][/url]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users