Forum Moderators: coopster
<?
include('common.php');
include('database.php');
session_start();
session_register('username');
session_register('userpass');
session_register('logout');
$username = $_SESSION['username'];
$userpass = $_SESSION['userpass'];
if (isset($logout)) {
unset($_SESSION['username']);
unset($_SESSION['userpass']);
unset($username);
unset($userpass);
}
?>
<HTML>
<HEAD>
<LINK REL=stylesheet HREF="style.css" TYPE="text/css">
<SCRIPT language="javascript" src="nav.js"></SCRIPT>
</HEAD>
<BODY style="background-color: #FFFFF0; background-image: url('/images/msgboard_2.jpg'); background-attachment: fixed; background-repeat: no-repeat;">
<?
if (!isset($username)) {
?>
<P>msgboard.php (logged out)</P>
<?
} else {
if (isset($username)) {
function CleanupSpaces($s) {
return trim(eregi_replace("[[:space:]]{2,}", " ", $s));
}
if (!isset($_POST['send'])) {
?>
<P><B><U>Submit new message</U>:</B><BR></P>
<P>
<FORM action="<?=$_SERVER['PHP_SELF']?>" method="post">
Subject:
<BR><INPUT type="text" name="subject" style="width: 400;" class="bord" value="<?=$subject?>" maxlength="100"><BR>
<TEXTAREA name="body" rows="12" style="width: 400;" wrap="on" class="bord" onkeypress="return getlength(this.value.length,2000)" onkeydown="textlen(this,2000)" onkeyup="textlen(this,2000)" onfocus="maxtext(this,2000)"></TEXTAREA><BR><BR>
<INPUT type="submit" name="post" value="send" style="height: 22px; width: 44px; font-size: 9px; font-weight: bold; font-family: Arial; border: 2px solid ivory" onFocus="if(this.blur)this.blur()">
</FORM>
</P>
<?
} if (isset($_POST['send'])) {
$poster = $username;
$subject = $_POST['subject'];
$body = $_POST['body'];
$date = date("M-d-Y H:i:s", time());
if ($subject==''){
?>
<P>
<FORM action="<?=$_SERVER['PHP_SELF']?>" method="post">
<span style="background-color: white; color: red;">Please enter a subject.</span><BR>
<span style="background-color: red;">Subject:</span>
<BR><INPUT type="text" name="subject" style="width: 400;" class="bord" value="<?=$subject?>" maxlength="40"><BR>
<TEXTAREA name="body" rows="12" style="width: 400;" wrap="on" class="bord" onkeypress="return getlength(this.value.length,200)" onkeydown="textlen(this,200)" onkeyup="textlen(this,200)" onfocus="maxtext(this,200)"></TEXTAREA><BR><BR>
<INPUT type="submit" name="send" value="send" style="height: 22px; width: 44px; font-size: 9px; font-weight: bold; font-family: Arial; border: 2px solid ivory" onFocus="if(this.blur)this.blur()">
</BLOCKQUOTE>
</FORM>
</P>
<?
}
if ($body==''){
?>
<P>
<FORM action="<?=$_SERVER['PHP_SELF']?>" method="post">
Subject:
<BR><INPUT type="text" name="subject" style="width: 400;" class="bord" value="<?=$subject?>" maxlength="40"><BR>
<span style="background-color: red; text-color: white;">Please enter some text:</span><BR>
<TEXTAREA name="body" rows="12" style="width: 400;" wrap="on" class="bord" onkeypress="return getlength(this.value.length,200)" onkeydown="textlen(this,200)" onkeyup="textlen(this,200)" onfocus="maxtext(this,200)"></TEXTAREA><BR><BR>
<INPUT type="submit" name="send" value="send" style="height: 22px; width: 44px; font-size: 9px; font-weight: bold; font-family: Arial; border: 2px solid ivory" onFocus="if(this.blur)this.blur()">
</BLOCKQUOTE>
</FORM>
</P>
<?
} else {
mysql_select_db($db, $con);
$sql = "insert into msgboard (poster, subject, body, date, reply) values ('$poster', '$subject', '$body', now(), '$reply')";
mysql_query($sql)or die("ERROR" .mysql_error());
mysql_close($con);
echo"<P>Your message has been posted.";
echo"<BR>Subject: $subject<BR>Message: $body<BR>Sent: $date<BR><BR><B>[ <span class='link'><A HREF='msgboard_newmsg.php' onFocus='if(this.blur)this.blur()'>Compose another message</A> ]</span></B></P>";
echo"<P><B>[ <span class='link'><A HREF='msgboard.php' onFocus='if(this.blur)this.blur()'>Return to the message board</A> ]</span></B></P>";
}
} else {
?>
<P>error displaying page. please contact us.</P>
<?
} } }
?>
</BODY>
</HTML>
Then you will be left with a good idea as to what is going on.
So instead of having all the forms visible, just have
print "this worked" or some other such message to make sure you got your logic sorted. Then when you have drop your stuff back in.
Cheers