My first script, and one thing id like to add, i dont know
php at all...i started to learn on the 2nd of november
2003, and well...thats 1 days experience.
For my first script i decided to make something to
convert tokens into credits, below is the script.
<?php $title = "Exchange Store"; include("header.php"); ?
>
<?php
$out = mysql_fetch_array(mysql_query("select * from
outposts where owner=$stat[id]")); ?>
Welcome to the exchange store, where you can
exchange your
tokens for credits.
<form method=post action=exchange.php?
action=exchange>
How many tokens do you want converted into credits
<input type=text size=3 value=0 name=tokexc> <input
type=submit value=exchange>
</form>
<?php
if ($action == exchange) {
$tokexc = str_replace("--","", $tokexc);
$tokgain = ($tokexc * .625);
if ($tokexc > $out[tokens]) {
print "You dont have that many tokens.";
include ("footer.php");
exit;
}
mysql_query("update players set
credits=credits+$tokgain where id=$stat[id]");
mysql_query("update outposts set tokens=tokens-
$tokexc");
print "You gained <b>$tokgain credits</b>.";
}
?>
<?php include("footer.php"); ?>
just paste that into notepad, wordpad etc, and call it
exchange.php
someone has probably made a script like that, or made
one more efficient, but there it is.
if you want to change the exchange rate, change:
$tokgain = ($tokexc * .625);
and just change the .625 to something else. as wat it is
set as, you get 5 credits for every 8.
you have to add the side link urself
and im working on a way to chage credits into tokens
Logged In: YES
user_id=899874
if you want to change credits into tokens just do the exact
same thing except change the SQL query
mysql_query("update players set
tokens=tokens+$creditgain where id=$stat[id]");
mysql_query("update outposts set credits=credits-
$creditexc");
Logged In: YES
user_id=500706
Can someone post a working copy of this code in a txt file.
This appears to have been corrupted when posted. Thanks
guys. Love your work :)