Math in php or MySql
I was on a site recently and wondered how they gave points to users. So I tried to do it on my own and can't seem to do it.
What I've done is I created a basic form.
There is a hiddenfield in the form that holds the users "points" from the database. We'll call this 'current_points'
There is another hiddenfield in the form that holds a pre-determined number (the points for posting the form). We'll call this "new_points".
And lastly there is yet another hiddenfield in the form that is suppose to hold the total of the two fields above.
So in other words - if they had 15 points and this post is worth 5 - then the third hiddenfield should end up with 20 in it and that will be updated in the user's points on the database.
<input name="current_points" type="hidden" id="current_points" value="<?php echo $row_Recordset1['points']; ?>" />
<input name="new_points" type="hidden" id="new_points" value="5" />
<input type="hidden" name="totalpts" id="totalpts" value="echo "Perform addition: $_POST['pts']; + $_POST['current_points']; = ".$addition."";"/>
This isn't working though. I'm getting an error saying I have double the same attribute. So I assume it is only looking at $_POST and not the field I want it to see.
Any thoughts?
