Monk3h Posted May 17, 2008 Share Posted May 17, 2008 This is a mini chat system im using, its displayed in the top right corner of my site, it works fine apart from when i click Chat to post a message it takes me to chat.php. How would i change this script so that it dosnt take me to chat.php but still does the action. =/ <?php Print"<center> <form method=post action=chat.php?action=minichat> <tr><td colspan=2 align=center> <input type=text name=msg size=15> <input type=submit value=Chat> </form></center>"; } if ($action == minichat) { if ($msg){ if ($stat[rank] == Admin) { $starter = "<span style=color:#0066cc>$stat[user]</span>"; } elseif ($stat[sub] > 0) { $starter = "<span style=color:#FF0000>$stat[user]</span>"; } elseif ($stat[rank] == Staff) { $starter = "<span style=color:#629632>$stat[user]</span>"; } else { $starter = "$stat[user]"; } mysql_query("insert into chat (user, chat) values('$starter', '$msg')"); mysql_query("update players set chatline=chatline+1 where id=$stat[id]"); } } ?> <iframe src=minichat.php width='100%' height=306 id=ifr name=ifr frameborder=0></iframe> </td></tr> </table><br> BTW, Chat .php is the main chat script. Quote Link to comment Share on other sites More sharing options...
phpzone Posted May 17, 2008 Share Posted May 17, 2008 I don't use Iframes much, but can you set a target on your form action eg. <form target=ifrm failing that, take a trip to ajax land ;-) Quote Link to comment Share on other sites More sharing options...
Monk3h Posted May 17, 2008 Author Share Posted May 17, 2008 I'm not sure.. Could you add what you mean to the script and ill give it a try? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted May 17, 2008 Share Posted May 17, 2008 this will almost certainly confuse browser(s) (form action defined twice due to missing quotes): <form method=post action=chat.php?action=minichat> should be: <form method='post' action='chat.php?action=minichat'> Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 17, 2008 Share Posted May 17, 2008 Use AJAX or have a redirect on the chat.php page. Ajax is your best bet. Quote Link to comment Share on other sites More sharing options...
Monk3h Posted May 17, 2008 Author Share Posted May 17, 2008 WTF is Ajax? :s Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 17, 2008 Share Posted May 17, 2008 Asynchronous Javascript and XML. It's basically using Javascript to send asynchronous requests to another file (IE, chat.php) so page reloads aren't necessary. PM me if you want a working example of Ajax on the user list I made on my little test site. xD 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.