Jump to content

Why isnt this script working?


BellQuestWars

Recommended Posts

<?php
session_start();
require_once("connect.php");
?>
<html>
<body>
Thanks for buying!<br> Receipt:<br> Amount:<?php echo ($_POST["amount"]);?>
<br>Type:<?php echo $_POST["type"];?>
<br>Cost:<?php
if($_POST["type"]=="pikemen"){
$cost = 20 * $_POST["amount"];
$price = $_SESSION["resources"] - $cost;
$name = $_SESSION["username"];
$gained = $_POST["amount"] + $_SESSION["pikemen"];
mysql_query("UPDATE SET pikemen = '$gained'
WHERE username = '$name'");
}
mysql_query("UPDATE SET resources = '$price'
WHERE username = '$name'");
?>
</body>
</html>

 

The script is supposed to use some information taken from an input box on the previous page to buy items from the shop, but its not working (it doesnt give errors, just doesnt change the amount of soldiers or resources...

Link to comment
Share on other sites

:( it still isnt even working, and I changed it to this:

<?php
session_start();
require_once("connect.php");
?>
<html>
<body>
Thanks for buying!<br> Receipt:<br> Amount:<?php echo ($_POST["amount"]);?>
<br>Type:<?php echo $_POST["type"];?>
<br>Cost:<?php
if($_POST["type"]=="pikemen"){
// MySQL connect information.
$c_username = "a1369434_bqw";
$c_password = "darthvader1";
$c_host = "mysql7.000webhost.com";
$c_database = "a1369434_bqw";

// Connect.
$connection = mysql_connect($c_host, $c_username, $c_password)
or die ("It seems this site's database isn't responding.");
$cost = 20 * $_POST["amount"];
$price = $_SESSION["resources"] - $cost;
$name = $_SESSION["username"];
$gained = $_POST["amount"] + $_SESSION["pikemen"];
mysql_query("UPDATE SET pikemen = '$gained'
WHERE username = '$name'");
echo $cost;
}mysql_query("UPDATE SET resources = '$price'
WHERE username = '$name'");
?>
</body>
</html>

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.