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
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
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.