pchopder Posted October 16, 2007 Share Posted October 16, 2007 //index.php <HTML> <body><pre> <form action="index.php" method="post"> Name:<input type="text" name="names"> Message:<input type="text" name="messages"> <input type="submit" value="Submit"> </form></pre> <? $message = $_POST['messages']; $name = $_POST['names']; if($message == ""){ print "No message here."; } else { if($name == ""){ print "Name was left blank so message was blocked."; } else { print "$name : $message" } } ?> </body> </HTML> What I'm trying to do is make a chatroom this is for 1 textbox but I'm trying to make it extend to 25 messages then erase the oldest but this one won't even work I'm not to great at php I'm a beginner I plan to design games and such in php but I don't plan on it soon due to the complexity of advanced php I'm just learning the basics now... [Edit] Sorry... the question is How do I manage to make this work with a form on top and the posted text below? Quote Link to comment Share on other sites More sharing options...
trq Posted October 16, 2007 Share Posted October 16, 2007 Sorry, but I don't see a question in your post. Quote Link to comment Share on other sites More sharing options...
jd2007 Posted October 16, 2007 Share Posted October 16, 2007 its better and good practice to have a separate php page.... the codes u have given have a problem : u forgot the semicolon ( here: print "$name : $message" please indent code properly like this : $message = $_POST['messages']; $name = $_POST['names']; if($message == "") { print "No message here."; } else { if($name == "") { print "Name was left blank so message was blocked."; } else { print "$name : $message"; } } Quote Link to comment Share on other sites More sharing options...
pchopder Posted October 16, 2007 Author Share Posted October 16, 2007 Thank you, jd2007 I did not know you could use Brackets "{, }" in different ways and the way you showed me is much less confusing Problem Solved!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.