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
Share on other sites

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.