Jump to content

Post vars + adding points


Ph0enix

Recommended Posts

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.

[code]

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

[/code]

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

Thanks!
Link to comment
https://forums.phpfreaks.com/topic/9505-post-vars-adding-points/
Share on other sites

1: You can use $_POST for this
[code]
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;
}
[/code]

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());
Link to comment
https://forums.phpfreaks.com/topic/9505-post-vars-adding-points/#findComment-35088
Share on other sites

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.