PDA

View Full Version : Starting my own Php Forum Script - Pro's Please Look



Braez
December 1st, 2005, 00:56
<h1>Add A Topic</h1>
<form method=post action="do_addtopic.php">
<strong>Topic Title:</strong><br>
<input type="text" name="topic_owner" size=40 maxlength=150>
<p><strong>Post Text</strong><br>
<textarea name="post_text" rows=8 cols=40 wrap=virtual></textarea>
<input type="submit" name="submit" value="Add Topic">
</form>


-----------------------
^^ Html Version so far ^^



<?php
//check for required fields from the form
if ((!$_POST[topic_owner]]) || (!@_POST[topic_title])
|| (!$_POST[post_text])) {
header("Location: addtopic.html");
exit;
}

//connect to server and select database
$conn = mysql_connect("locathost", "jouser", "somepass")
or die(mysql_error());
mysql_select_db("testDB",$conn) or die(mysql_error());

//create and issue the first query
$add_topic = "insert into forum_topics values ('', '$_POST[topic_title]',
now(), '$_POST[topic_owner]')";
mysql_query($add_topic,$conn) or die(mysql_error());

//get the id of the last query
$topic_id = mysql_insert_id();

//create and issue the second query
$add_post = "insert into forum_posts values ('', '$topic_id',
'$_POST[post_text]', now(), '$_POST[topic_owner]')";
mysql_query($add_post,$conn) or die(mysql_error());

//create nice message for user
$msg = "<p>The <strong>$topic_title</strong> topic has been created.</p>";
?>
<html>
<head>
<h1>New Topic Added</h1>
<?php echo $msg; ?>
</body>
</html>

<?php
//connect to server and select database
$conn = mysql_connect("locathost", "joeuser", "somepass")
or die(mysql_error());
mysql_select_db("testDB",$conn) or die(mysql_error());

//gather the topics
$get_topics = "select topic_id, topic_title,
date_format(topic_create_time, '%b %e %Y at %r') as fmt_topic_create_time,
topic_owner from forum_topics order by topic_create_time desc";
$get_topics_res = mysql_query($get_topics,$conn) or die(mysql_error());
if (mysql_num_rows($get_topics_res < 1) {
//there are no topics, so say so
$display_block = "
<table cellpadding=3 cellspacing=1 border=1>
<tr>
<th>TOPIC TITLE</th>
<TH># OF posts</th>
</tr>";

while ($topic_info = mysql_fetch_array


It's no where near finished, and that page's aren't marked in but how's it looking so far??

Thanks.

freak127
December 1st, 2005, 11:45
Well, you have spelt 'localhost' wrong near the beginning ;) .
Do you have a demo of this up anywhere, so I could see it?
Also, I am currently writing my own forum script as well, but I have only got a user system up at the moment :P .

Tree
December 1st, 2005, 21:32
I was going to look at this, but the guy who posted this is banned. So I see no point.

stuffradio
December 2nd, 2005, 00:40
Why is he banned?