PDA

View Full Version : php code erros not instretn name of auther in to sql db


sytodave88
05-20-2007, 05:47 PM
when the user cretaes a topic it goes to db then once user clicks the topic he has made it should show his name at top of topic as well but it is not geten instred to the db . $name is the usernames name

<?
session_start();
$UPDATE_DB = 1;
include("includes/_include-config2.php");
include("includes/ban.php");
include_once "includes/functions.php";
require("conf.php");
include("functions.php");
if(! check_login()) {
header("Location: http://localhost/frameset%20new%20layout/login.php");
exit;
}

mysql_query("UPDATE `[users]` SET `online`=NOW() WHERE `login`='{$data->login}'");

$ok = 0;

$name = $data->login;
$bericht=$_POST['bericht2'];
$subject=$_POST['subject2'];

if($_POST["submit"]) {
require("conf.php");
$ok = 1;

if(empty($subject))
$err[] = "You've forgotten your subject!";



if(empty($bericht))
$err[] = "You've forgotten your message!";

for($i=0;$i<sizeof($bad_words);$i++)
if(ereg($bad_words[$i], $name) || ereg($bad_words[$i], $subject) || ereg($bad_words[$i], $bericht))
$err[] = "We like to keep our forum desent. Please use some normal language!";

if(sizeof($err) > 0) {
?>

<?
for($i=0;$i<=sizeof($err);$i++)
echo "\n\t<font class=\"Error\">".$err[$i]."</font><br>";
?>
<input type="submit" STYLE="border:2px solid;color:#000000; background-color:#FF8C00" value="Back">
</form>
</td>
</tr>
</table>
</td></tr>
</table>
</body>
</html>
<?
} else {
$name = $data->login;
require_once("inc/mysql_connect.php");
$sql = "INSERT INTO forum_off_topics (topic_id, title, author, post, date, lastpost) VALUES ('', '$subject', '$name', '$bericht', NOW(), NOW())";
mysql_query($sql) or die("<h1>Something went wrong</h1><hr>".mysql_error());
header('Location: index.php');

if($reply <> 0) {
$sql = "UPDATE forum SET replys = replys + 1 WHERE id = '$reply'";
mysql_query($sql) or die("<h1>Something went wrong</h1><hr>".mysql_error());
}

if($reply != 0) {
header('Location: read.php?id=$reply');
}
}
} else {
if(!isset($reply))
$reply = 0;
?>
<html>

<head>
<title>Forum</title>
<link rel="stylesheet" type="text/css" href="inc/style.css">
<script language="JavaScript">
<!--
function SubmitOnce(theform) {
// if IE 4+ or NS 6+
if (document.all || document.getElementById) {
// hunt down "submit" and "reset"
for (i=0;i<theform.length;i++) {
var tempobj=theform.elements[i];
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") {
//disable it
tempobj.disabled=true;
}
}
}
}
//-->
</script>
</head>

<body topmargin="0" background="images/main_r2_c2.gif">
<p>&nbsp;</p>
</table>
<table width="90%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr>
<td background="images/content_top.jpg"><b>New Topic</b></td>
</tr>
<tr>
<td valign="top" align="left" class="NormalText">
<form name="postform" onsubmit="SubmitOnce(this);" method="POST" action="<?=$PHP_SELF?>">
Subject:&nbsp;
<input type="text" name="subject2"><br>
<textarea name="bericht2" rows="8" cols="40"></textarea><br>
<input type="hidden" name="reply" value="<?=$reply?>">
<input type="hidden" name="submit" value="true">
<input type="submit" STYLE="border:2px solid;color:#000000; background-color:#FF8C00" value="Submit" >
</form>
<?
}
?>
</td>
</tr>
</table>
</td></tr>
</table>
</body>
</html>