Jump to content

[SOLVED] INSERT problem


R1der

Recommended Posts

Ok i have made a classifieds page but when you click "Post" it inserts the 'id' 'username' but when it comes to adding the 'text' part it INSERTS '0' and i cant understand why :S Can anyone help with this?

 

<?

session_start();

include("gameconfig.php");

$title = "Classifieds";

if(!$email || !$password){
error("field");
exit;
}

if($playerinfo[password] != $password){
error("password");
}else{
include("top.php");
$cost=1000*$playerinfo['level'];
echo "<center>Tribal Classifieds<br><br></center>";
echo "<center>It will cost you $cost gold to post a advertisement<br><br></center>";
echo "<center><form method=post action=classifieds.php?action=post>Advertise: <input name=post size=12> <INPUT TYPE=SUBMIT VALUE=Post></FORM></center>";
$select = mysql_query("select * from classifieds order by id DESC LIMIT 20");
while($lis = mysql_fetch_array($select))
if($playerinfo['status'] !="Member"){
echo "<center>[<a href=classifieds.php?step=delete&id=$lis[id]>D</a>] ";

echo "$lis[username]: $lis[text]</center><br>";
}else{
echo "$lis[username]: $lis[text]</center><br>";
}
if($action == "post")
{
$post = abs($post);
$post = str_replace("-","",$post);
$cost=1000*$playerinfo['level'];
if($playerinfo['gold'] > $cost){
mysql_query("UPDATE userdb set gold=gold-$cost WHERE id='$playerinfo[id]'");
mysql_query("INSERT INTO classifieds (id, username, text) VALUES ('', '$playerinfo[username]', '$post')") or die(mysql_error());
echo "<center>You sucessfully added your advertisement.</center>";
}else{
echo "<cener>You do not have enough gold to proceed</center>";
}
}
  if ($step == delete)
            {
            echo "News deleted. <a href=classifieds.php>Back</a>";
            $remove = mysql_query("delete from classifieds where id='$id'");
            }


include("bottom.php");
}
?>

 

Thanks.

 

Oh and also can you tell me if my code (test box) is secure enough from sql injections?

 

Thanks for your time

Link to comment
https://forums.phpfreaks.com/topic/54240-solved-insert-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.