Jump to content

Recommended Posts

form2.php

 

<?php
session_start();
if (empty($_SESSION['is_logged_in']))
{
header("Location:chatframe.php");
die();     // just to make sure no scripts execute
} 
?>
<?php
mysql_connect("localhost","root") or die(mysql_error());
mysql_select_db("cute") or die(mysql_error());
$message=$_POST['message'];
$a=$_SESSION['username'];



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

{


   if(strlen($message)>1)
   {
      $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('$a','$IP','$thedate','$message')";
     mysql_query($insertmessage) or die("Could not insert message");
    }
    $a="window.location.replace('chatlog2.php')",2000);

    echo "<html>
    <head>
    <script>
     setTimeout($a);
     var objDiv = document.body;
     objDiv.scrollTop = objDiv.scrollHeight;
   </script>
   </head>
</html>";
   }
}


?>
<html>
<head>
<script type="text/javascript">
function addsmiley(code)
{
var pretext = document.smile.message.value;
              this.code = code;
              document.smile.message.value = pretext + code;
}

function a()
{
var x = document.smile.message.value;
if(x=="")
{
  alert("Please insert an message!");
  return false;
}

}

</script>
<style type="text/css">
body{ background-color: #d8da3d }
</style>
</head>
<body>
<center>
  <form name="smile" method="post" action="form2.php" onSubmit="return a()" >
   Your message:&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <a style="text-decoration:none" <a href="javascript: void(0)"
   onclick="window.open('banip.php',
  'windowname2',
  'width=400, \
   height=150, \
   directories=no, \
   location=no, \
   menubar=no, \
   resizable=no, \
   scrollbars=1, \
   status=no, \
   toolbar=no');
  return false;">Action</a>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
   <a style="text-decoration:none" href="logout.php">Sign Out</a><br><textarea name='message' cols='40' rows='2'></textarea><br>
   <img src="smile.gif" alt="" onClick="addsmiley('')" style="cursor:pointer;border:0" />
   <img src="blush.gif" alt="" onClick="addsmiley('*blush*')" style="cursor:pointer;border:0" />
    &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
   <input type='submit' name='submit' value='Send' class='biasa'  ></form>

   

  <br> <br>
  </center>
  </body>
</html>

 

 

 

which is wrong and can you please modified it ?

Link to comment
https://forums.phpfreaks.com/topic/252995-coding-error-misput-the-script/
Share on other sites

We're not going to simply read through your entire script and hand you back a fixed version.

 

Do you have a specific question/problem?

 

 

actually my problem is after im click the button send im want the chatlog to be refresh on the bottom but still its does not refresh to bottom may i know where is the problem

What errors you getting by this script ?

 

<?php
session_start();
if (empty($_SESSION['is_logged_in']))
{
header("Location:chatframe.php");
die();     // just to make sure no scripts execute
} 
?>
<?php
mysql_connect("localhost","root") or die(mysql_error());
mysql_select_db("cute") or die(mysql_error());
$message=$_POST['message'];
$a=$_SESSION['username'];



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

{


   if(strlen($message)>1)
   {
      $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('$a','$IP','$thedate','$message')";
     mysql_query($insertmessage) or die("Could not insert message");
    }
    $a='chatlog2.php';

    echo "<html><head>
    <script>
     setTimeout('window.location.replace($a)',2000);
     var objDiv = document.body;
     objDiv.scrollTop = objDiv.scrollHeight;
   </script>
   </head>
</html>";
   }
}


?>
<html>
<head>
<script type="text/javascript">
function addsmiley(code)
{
var pretext = document.smile.message.value;
              this.code = code;
              document.smile.message.value = pretext + code;
}

function a()
{
var x = document.smile.message.value;
if(x=="")
{
  alert("Please insert an message!");
  return false;
}

}

</script>
<style type="text/css">
body{ background-color: #d8da3d }
</style>
</head>
<body>
<center>
  <form name="smile" method="post" action="form2.php" onSubmit="return a()" >
   Your message:&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <a style="text-decoration:none" <a href="javascript: void(0)"
   onclick="window.open('banip.php',
  'windowname2',
  'width=400, \
   height=150, \
   directories=no, \
   location=no, \
   menubar=no, \
   resizable=no, \
   scrollbars=1, \
   status=no, \
   toolbar=no');
  return false;">Action</a>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
   <a style="text-decoration:none" href="logout.php">Sign Out</a><br><textarea name='message' cols='40' rows='2'></textarea><br>
   <img src="smile.gif" alt="" onClick="addsmiley('')" style="cursor:pointer;border:0" />
   <img src="blush.gif" alt="" onClick="addsmiley('*blush*')" style="cursor:pointer;border:0" />
    &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
   <input type='submit' name='submit' value='Send' class='biasa'  ></form>

   

  <br> <br>
  </center>
  </body>
</html>

 

 

This one no error but still when im click send button message its does not refresh to bottom of the chatlog2.php, may i know where is wrong

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.