Here it is.
Don't blame with my code or it doesn't work.
Because this is not tested.
Errors? fix it self, this is only a base of whatever.
PHP Code:
if (isset($_POST['submit']))
{
$error = 0;
if (!empty($_POST['pixels']))
{
$pixels = $_POST['pixels'];
}
else
{
$error = 1;
}
if (!$error)
{
$oldpixels = mysql_result(dbquery("SELECT `pixels` FROM `users` WHERE `id` = '".USER_ID."' LIMIT 1"), 0);
if ($oldpixels <= $pixels) //Idk if this right, because i always mix the > and < ...
{
$newcredits = $pixels / 10;
$users->givecredits(USER_ID, $newcredits);
$newpixels = $oldpixels - $pixels;
dbquery("UPDATE `users` SET `pixels` = '".$newpixels."' WHERE `id` = '".USER_ID."' LIMIT 1");
}
else
{
$error = 1;
}
}
if ($error)
{
//go to error page, or what you want
header("location: http://".WWW."/your page error.php");
exit;
}
//go to succes page, or what you want
header("location: http://".WWW."/your page succes.php");
exit;
}