Jump to content

[SOLVED] Need help finding siple error in script...


DiscoTrio

Recommended Posts

Ok everything works but the output become 0 on chat.  It makes message become a 0.  I know its in this part of code becuase thats what goes into the database.

 

Here is the input code:

 

<?php

 

include "connect.php";

 

if(isset($_POST['submit'])) //if submit button push has been detected

 

{

 

  $message=$_POST['message'];

 

  $name=$_POST['name'];

 

  if(strlen($message)<1)

 

  {

 

      print "You did not input a message";

 

  }

 

  else if(strlen($name)<1)

 

  {

 

      print "You did not enter a name, please try again.";

 

  }

 

  else

 

  {

 

      $message=strip_tags($message);

 

      $IP=$_SERVER["REMOTE_ADDR"]; //grabs poster's IP

 

      $checkforbanned="SELECT IP from ipbans where IP='$IP'";

 

      $checkforbanned2=mysql_query($checkforbanned) or die("Could not check for banned IPS");

 

      if(mysql_num_rows($checkforbanned2)>0) //IP is in the banned list

 

      {

 

        print "You IP is banned from posting.";

 

      }

 

      else

 

      {

 

        $thedate = date("U"); //grab date and time of the post

 

        $insertmessage="INSERT into chatmessages (name,IP,postime,message) values('$name','$IP','$thedate','$message')";

 

        mysql_query($insertmessage) or die("Could not insert message");

 

   

 

 

 

      }

 

  }

 

 

 

     

 

}

 

print "<form action='submit.php' method='post' name='form'>";

 

print "Your name:<br>";

 

print "<input type='text' name='name' size='20'><br>";

 

print "Your message:<br>";

 

print "<textarea name='message' cols='40' rows='2'></textarea><br>";

 

print "<a onClick=\"addSmiley(':)')\"><img src='images/smile.gif'></a> "; //replace images/smile.gif with the relative path of your smiley

 

print "<a onClick=\"addSmiley(':(')\"><img src='images/sad.gif'></a> ";

 

print "<a onClick=\"addSmiley(';)')\"><img src='images/wink.gif'></a> ";

 

print "<input type='submit' name='submit' value='submit'></form>";

 

print "<script language=\"Java Script\" type=\"text/javascript\">\n";

 

print "function addSmiley(textToAdd)\n";

 

print "{\n";

 

print "document.form.message.value += textToAdd;";

 

print "document.form.message.focus();\n";

 

print "}\n";

 

print "</script>\n";

 

print "<br><br>";

 

 

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.