homepage Welcome to WebmasterWorld Guest from 54.242.241.20
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
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

10+ Year Member



 
Msg#: 4768 posted 1:42 am on Aug 17, 2004 (gmt 0)

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

10+ Year Member



 
Msg#: 4768 posted 4:59 am on Aug 17, 2004 (gmt 0)

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

WebmasterWorld Administrator ergophobe us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4768 posted 3:23 pm on Aug 17, 2004 (gmt 0)

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

mylungsarempty

10+ Year Member



 
Msg#: 4768 posted 2:58 am on Aug 18, 2004 (gmt 0)

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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4768 posted 7:52 am on Aug 18, 2004 (gmt 0)

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

10+ Year Member



 
Msg#: 4768 posted 7:22 pm on Aug 18, 2004 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved