Jump to content

Message Board - Not working


fredundant

Recommended Posts

EDIT: PLEASE IGNORE/MOD DELETE. SPOTTED SO MUCH WRONG WITH THIS

 

Sorry to post again so soon But you'll see I've been working hard since my last problem.

 

What I'm trying to achieve is a message board where a user posts a message and the message appears at the top of previously added messages. And at the end it says who posted it and when.

 

This is my code

 

<?php
;
session_start();
//this checks to see if the $_SESSION variable has been not set 
//or if the $_SESSION variable has been not set to true
//and if one or the other is not set then the user gets
//sent to the login page
if (!isset($_SESSION['username'])) {
    header('Location: http://mydomain/login.php');
}




?>




<HTML>
<head><title>Message Board - Logged In</title>
<link rel='stylesheet' href='layout.css'>
</head>
<body bgcolor="#fd8ecf">
<center><img src="headerpage.jpg"></center>

<div class="navbar">
<div class="button"><a href="index.html">Home</a></div>
<div class="button"><a href="news.html">News</a></div>
<div class="button"><a href="gallery.html">Gallery</a></div>
<div class="button"><a href="videos.html">Videos</a></div>
<div class="button"><a href="contact.html">Contact</a></div>
<div class="button"><a href="links.html">Links</a></div>
<div class="button"><a href="msg.html">Message  Kaaleigh</a></div>

</div>

<div class="frame">

<frameset cols="25%,75%" noresize="noresize">

<?php
session_start();

$username = $_SESSION['username'];
$password = $_SESSION['password'];

  if(isset($_SESSION['username']) && isset($_SESSION['password'])) {
    
  echo " <b>Welcome ".$username." <br><br></b>";
  }

    else {
    echo "Welcome Guest! <br> <a href=login.php>Login</a> | <a href=register.php>Register</a>";
    }

?>


<?php
mysql_connect("******", "*********", "*********");
mysql_select_db("**********");
?>






<form action="commentboard.php" method="POST">
Your Name: <input type="text" name="author"><br>
Message:<br><textarea cols="60" rows="5" name="message"></textarea><br>
<input type="submit" value="Post Thread">
</form>




<?php
mysql_connect("*********", "*********", "******");
mysql_select_db("**********");
$time = time();
mysql_query("INSERT INTO messages VALUES(NULL,'$_POST[message]','$_POST[author]','0','$time')");
echo "Message Posted.<br><a href='messageboard.php'>Return</a>";


<?php
// I am selecting everything from the messages section in the database and ordering them newest to oldest.
$sql = mysql_query("SELECT * FROM messages ORDER BY posted DESC");

// Now I am getting my results and making them an array
while($r = mysql_fetch_array($sql)) {

$posted = date("jS M Y h:i",$r[posted]);

// End of Array
}
?>


</body>


</html>

 

This page is /messageboard.php

 

Nothing is happening. It seems to just not work and I cant for the life of me see why.

Also What I'd prefer is instead of the user typing author into the form is they just type a message into the message database and the user name automatically fills itself in from the session of the users table.

 

But for now my main concern is nothing working

 

Any ideas?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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