Jump to content

not doing anything.


grlayouts

Recommended Posts

when i hit sell 400 drugs it does nothing updates nothing and doesnt print anything.

 

<?php
print "<form method=post action=cmarket.php?view=sell&step=sell>Sell <input name=amount><select name=seller><option value=drugs>Drugs</option></select>. <input type=submit value=Sell></form>";
if ($step == "sell") 
{
switch($seller)
{
	case "drugs":
		if ($stat['drugs'] < $amount) {
			print "Sorry mate, you don't have the drugs.";
		} else {
			mysql_query("update players set drugs=(drugs-$amount) where id=".$stat[id]);
			mysql_query("update players set credits=($amount*".$stat['drugprice'].") where id=".$stat['id']);
			print "You sold $amount of drugs."; 
		}
	break;
	case "SteakHouse":
		if ($stat[credits] < 60000) {
			print "Sorry mate, you don't have the cash.";
		} else {
			mysql_query("update players set steakhouse=steakhouse+1 where id=$stat[id]");
			mysql_query("update players set credits=credits-60000 where id=$stat[id]");
			mysql_query("update players set employees=employees+10 where id=$stat[id]");
			print "Steak Building added."; 
		}
	break;
}
}
?>

Link to comment
Share on other sites

To access post variables use the $_POST[] super-global array.

 

if ($_POST['step'] == "sell") 
{
switch($_POST['seller'])
{
	// ...
}
}

 

I also recommend both checking for valid and safe input as well as that there is input to begin with using isset(). Also, put quotes around attribute values in your html; <form method="POST" action=".... 

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.