Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Php - chatbox ! Need help

imblaze

Recruit
Basic Member
Messages
1
Reaction score
0
Points
16
NEED HELP !!! PLEASE HELP ME HOW CAN I MAKE IT WORK . THANKS IN ADVANCE

index.php
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Chat box</title>

<script>
function submitChat(){
if (chatbox.uname.value =='' || chatbox.msg.value =='') {
alert('All Fields are Mandatory');
return;
};
var uname = chatbox.uname.value;
var msg = chatbox.msg.value;
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
var xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState==4&&xmlhttp.status==200) {
document.getElementById('chatlogs').innerHTML = xmlhttp.responseText;
};
}
xmlhttp.open('POST' , 'insert.php?uname='+uname+'&msg='+msg, true);
xmlhttp.send();
}
</script>
</head>
<body>
<form action="" name="chatbox" method="GET">
Enter Your Chatname: <input type="text" name="uname" /> <br />
Your Message: <br />
<textarea name="msg" cols="30" rows="10">
</textarea>
<br>
<a href="" onclick="submitChat()">Send</a><br /> <br />
<div id="chatlogs">
Loading Chat . . . Please wait
</div>
</form>
</body>
</html>

insert.php
<?php
$uname = $_REQUEST['uname'];
$msg = $_REQUEST['msg'];
$con = mysql_connect("localhost" , "root" ,"");
mysql_select_db('chatbox' , $con);
mysql_query("INSERT INTO logs ('username' , 'message') values ('$uname' , '$msg')") or die("EROORORORO");
$result1 = mysql_query("SELECT * FROM logs ORDER BY id DESC");
while ($extract = mysql_fetch_array($result1)) {
echo $extract['username'] . ": " . $extract['message'] . "<br />";
}
?>
 
Last edited:
what is the error?or anu ang problema sa code
 
try mu sir ung form action mu .. ilagay mu ung insert.php..?? try lng
 
paki explain na lang po kung ano yung error nito, mahirap naman kapag kami pa maghanap ng error mo :)
 
Actually copy paste na to, try read it on the page where you get this. Pinaliwanag yan dun, wala na kasi ako time para i explain.. HAHA ubus na oras ko HAHAH :P
 
try mo lagay sa form ung insert.php

<form action="" name="chatbox" method="GET">


<form action="insert.php" name="chatbox" method="GET">

kung ang error mo po ay everytime n kiniclick mo yung send button wala po nangyayari..

:)
 
Back
Top Bottom