Jump to content

re write in ajax


conan318

Recommended Posts

hi i am trying to make place where users can post messages to each other i have it working in php but the trouble the page needs to refresh for it work.

looking for some help to write in this in ajax. i have no experience with ajax  so if someone could point me in the right direction much appreciated

<div class="form">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  
  
  <INPUT type="text" name="message" SIZE="30"   VALUE="">  
<input type="hidden" name="submit"  value="Update Status">
   
</form>
</div>
<div class="posts" id="posts" style="display: block;">

<?php

$data = mysql_query("SELECT * from cvisinko_db.posts,users WHERE posts.username=users.username   ORDER BY  posts.id DESC LIMIT 10;") or die(mysql_error());
  



while($info = mysql_fetch_array( $data )) 
{
echo "<img src='img/".$info['img'] ."' width='30' height='30''>"." ". $info['username'].": ".$info['message']."<br>";
echo "<hr>";
}


if(isset($_POST['submit']))
{
    $message = $_POST['message'];
    mysql_query("INSERT INTO cvisinko_db.posts (message, username ) VALUES ('$message','$myusername')") OR die("Could not send the message: <br>".mysql_error()); 
}
?>

Link to comment
https://forums.phpfreaks.com/topic/246507-re-write-in-ajax/
Share on other sites

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.