Welcome to WebmasterWorld Guest from 54.160.131.144

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

I'm a little rusty, and can't figure out why this script won't work...

all it's supposed to do is submit a message, but there is some problem

     

mylungsarempty

1:42 am on Aug 17, 2004 (gmt 0)

10+ Year Member



all it's supposed to do is submit a message, but there is some problem i cant figure out here... i haven't coded in a while and i'm a little rusty here... here's the whole page. (the error is definitely not in any of the includes.)
=========---------

<?

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>

m_shroom

4:59 am on Aug 17, 2004 (gmt 0)

10+ Year Member



I didn't look it over to well, but I use full tags " <?php " to avoid problems and you have one of your tags inside an if statment asking for trouble.

ergophobe

3:23 pm on Aug 17, 2004 (gmt 0)

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Can you tell us
- what the error message or specific problem is
- if there is an error message, what line is referenced?

mylungsarempty

2:58 am on Aug 18, 2004 (gmt 0)

10+ Year Member



There's no error message.

it just displays the wrong way and doesn't actually submit a message. There's some error on the syntax of all my if/else statements. I think i may just start this page over . . .

ukgimp

7:52 am on Aug 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Strip it back to bare bones, take all the crap out.

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

mylungsarempty

7:22 pm on Aug 18, 2004 (gmt 0)

10+ Year Member



good thinking. it's weird how just a couple of months off from programming can let you forget so much.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month