Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 403
1 Users 9 Guests Online

Send Points

Mentioned by -=InSaNe=- made by SkillMaster

Save as send_points.php
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
session_start
();
include 
"config.php";
if(
$logged[username])
{
switch(
$_GET[page])
{
default:
echo (
"
You have <b>
$logged[points]</b> points in hand to send.<br>
<form method='post' action='?page=send'>
<select name='username'>"
);
$fetch mysql_query("SELECT * FROM `members`");
while (
$user mysql_fetch_array($fetch))
{
echo (
"<option value='$user[username]'>$user[username]</option>");
}
echo (
"
</select><br>
<input type='text' name='points' size='20'>
<input type='submit' name='submit' value='Send'>"
);
break;

case 
'send':
$username strip_tags(htmlspecialchars($_POST[username]));
$points strip_tags(htmlspecialchars($_POST[points]));
if (
$logged[points] < $points)
{
echo (
"You don't have that many points. <a href='send_points.php'>Back</a>");
}
elseif (
$points == NULL)
{
echo (
"Please enter a value of points. <a href='send_points.php'>Back</a>");
}
else
{
$fetch mysql_query("SELECT * FROM `members` WHERE `username` = '$username'");
$user mysql_fetch_array($fetch);

$points1 $logged[points]-$points;
$points2 $user[points]+$points;

$update1 mysql_query("UPDATE `members` SET `points` = '$points1' WHERE `username` = '$logged[username]'");
$update2 mysql_query("UPDATE `members` SET `points` = '$points2' WHERE `username` = '$username'");
echo (
"You have sent $points to $username. <a href='send_points.php'>Back</a>");
}
break;
}
}
?>


Code

$fetch = mysql_query("SELECT * FROM `members`");
while ($user = mysql_fetch_array($fetch))
{
echo ("<option value='$user[username]'>$user[username]</option>");
}

Displays all of our users.

Code

<form method='post' action='?page=send'>
<select name='username'>");
$fetch = mysql_query("SELECT * FROM `members`");
while ($user = mysql_fetch_array($fetch))
{
echo ("<option value='$user[username]'>$user[username]</option>");
}
echo ("
</select><br>
<input type='text' name='points' size='20'>
<input type='submit' name='submit' value='Send'>");

Our form to define our variables.

Code

if ($logged[points] < $points)
{
echo ("You don't have that many points. <a href='send_points.php'>Back</a>");
}

if the users points is less than the points they are trying to send they get an error messge

Code

$points1 = $logged[points]-$points;
$points2 = $user[points]+$points;

$update1 = mysql_query("UPDATE `members` SET `points` = '$points1' WHERE `username` = '$logged[username]'");
$update2 = mysql_query("UPDATE `members` SET `points` = '$points2' WHERE `username` = '$username'");
echo ("You have sent $points to $username. <a href='send_points.php'>Back</a>");

Does out math and then updates the database gives us a success message.

That it.
Live earth on soon.
SkillMaster
Views:
2232
Rating:
Posted on Tuesday 8th April 2008 at 06:44 PM
Dalez
Dalez
You can send points to yourself, and they keep adding up!

How do i fix this?
Posted on Tuesday 8th April 2008 at 02:20 AM
UrbanTwitch
UrbanTwitch
How do you get points?!
Posted on Sunday 18th November 2007 at 08:09 PM
awo
awo
Ops... sory :S wrong Tuborials :S
Posted on Thursday 15th November 2007 at 09:35 PM
awo
awo
the code is not good!!!!

i can take -10000000000 points in the Withdraw and get the points :S
Posted on Wednesday 24th October 2007 at 11:46 PM
darklight19
darklight19
I can't get this to work, it's just making the page blank. I looked at the code counted the brackets, changed some code. And still...nothing
Posted on Tuesday 17th July 2007 at 06:31 AM
gbt91
gbt91
lol code function isnt working :S
Posted on Tuesday 17th July 2007 at 06:31 AM
gbt91
gbt91
[CODE]
ALTER TABLE `members` ADD `*New Field Name*` VARCHAR( 225 ) NOT NULL,
[/CODE]
Posted on Tuesday 17th July 2007 at 06:30 AM
gbt91
gbt91
Skill noobs can think it's all here but you forgot to add this xD
[CODE]ALTER TABLE `members` ADD `points` VARCHAR( 225 ) NOT NULL [/CODE]
Posted on Saturday 30th June 2007 at 01:02 PM
cyruswu
cyruswu
Almost scared me. Thank god no rip!