I am creating a client account management area on my site (check balance, pay your bill, print/save our contract, check progress, upload files/content, write messages to one another.. I have just about everything going smoothly (thanks entirely to a lot of info and help here @ DaniWeb)..
One issue I am having is the notes board - I can write a message and submit: posts fine (actually, posts the same message twice)... THEN... if I click refresh - it will post a "blank" message (inserts a line w/horizontal rule, essentially - posting a blank message with time stamp.. ) The goal of the noteboard is to allow communication between myself and client - quick notes about progress/design.
It is actually not just posting a BLANK message... for example: I just typed in "1" and pressed submit... "1" came up TWICE (and the message box was cleared to make room naturally for another message, since this would be a "new session"). THEN - with the BLANK box, I press submit - and once again, two more lines with the "1" message... even though the box was empty?
Pardon my ignorance, only been dealing with PHP for... 24 hours?
Posted by client1 on 2011-03-18
-------
Posted by client1 on 2011-03-18
-------
Posted by client1 on 2011-03-18
1
-------
Posted by client1 on 2011-03-18
1
-------
Posted by client1 on 2011-03-18
1
-------
Posted by client1 on 2011-03-18
1
-------
==========================
Here is my NOTEBOARD.PHP code:
<?php
session_start();
if(!isset($_SESSION['username'])){
header( 'Location: loginform.html' );
}
require('db.php');
$client_ID = mysql_query("SELECT client_ID
FROM clients WHERE username='".$_SESSION['username']."'")or die(mysql_error());
$client_ID = mysql_fetch_array($client_ID);
$client_ID = $client_ID['client_ID'];
mysql_query("
INSERT INTO noteboard(client_ID, date, message)
VALUES('$client_ID', CURDATE(), '$_POST[message]')
");
if(!empty($_POST[message]))
mysql_query("
INSERT INTO noteboard(client_ID, date, message)
VALUES('$client_ID', CURDATE(), '$_POST[message]')
");
#
// Displays all current notes
$getNotes = mysql_query("SELECT * FROM noteboard WHERE client_ID='".$client_ID."' ORDER BY date");
while($row = mysql_fetch_array($getNotes, MYSQL_ASSOC)){
echo "Posted by " . $_SESSION['username'] . " on " . $row['date'] . "<br /><p>"
. $row['message'] . "</p><hr />";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Your Portfolio - Client Area - Note Board</title>
</head>
<body>
<form action="noteboard.php" method="post">
<h3>Message:</h3><br />
<textarea name="message" cols="30" rows="10"></textarea><br />
<input type="submit" value="Submit" />
</body>
</html>