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