|
Ok so I made a simple forum thing, but the problem is that users cannot post replies since my code does not seem to allow them to add anything to the database. Here is my code after they press submit
<?php
session_start();
function quote_smart($value)
{
$value = stripslashes($value);
if (!is_numeric($value))
$value = "'" . mysql_real_escape_string($value) . "'";
return $value;
}
include("../common.php");
?>
<?php
$uname = $_SESSION['name'];
$com = $_POST['comments'];
$uname = htmlspecialchars($uname);
$com = htmlspecialchars($com);
$user_name = "root";
$pass_word = "";
$database = "TestForum";
$server = "127.0.0.0";
$db_handle = mysql_connect($server, $user_name, $pass_word);
$db_found = mysql_select_db($database, $db_handle);
if($db_found)
{
$uname = quote_smart($uname, $db_handle);
$com = quote_smart($com, $db_handle);
$SQL = "INSERT INTO forum (name, reply) VALUES($uname, $answer)";
$result = mysql_query($SQL);
mysql_close($db_handle);
confirm("ALL DONE");
}
else
{
confirm ("Database NOT Found ");
mysql_close($db_handle);
}
?>
The confirm function is included in the common.php and all it does is pop out alert box with said message. Now whenever I run this script on my web I get the ALL DONE message every time, but upon checking the database table I see absolutely nothing added. I tried absolutely anything and nothing seems to work. Any help?
(I changed the username, password, database and server name just for security purpose so that's not the error).
Thanks a lot for the help in advance
__________________
Those who can: learn. Those who can't: teach.
|